### Get Processing Points Example Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/release_notes.md Demonstrates how to retrieve the geometric points of a processing for a given element and processing ID. This example iterates through BTL processings and fetches their points. ```python def get_processing_points(reference_element_id: int, processing_id: int) -> vertex_list: """Get the points of a processing. Parameters: reference_element_id: The reference element ID. processing_id: The processing ID. Examples: >>> import cadwork >>> import element_controller as ec >>> import machine_controller as mc >>> element: int = 123456789 >>> processings = mc.get_element_btl_processings(element, cadwork.btl_version.btlx_2_1.value) >>> for processing in processings: >>> points = mc.get_processing_points(element, processing) Returns: A vertex_list of points. """ ``` -------------------------------- ### Get Processing Code Example Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/release_notes.md Demonstrates how to retrieve the code of a processing for a given element and processing ID. This example iterates through BTL processings and fetches their codes. ```python def get_processing_code(reference_element_id: int, processing_id: int) -> str: """Get the code of a processing. Parameters: reference_element_id: The reference element ID. processing_id: The processing ID. Examples: >>> import cadwork >>> import element_controller as ec >>> import machine_controller as mc >>> element: int = 123456789 >>> processings = mc.get_element_btl_processings(element, cadwork.btl_version.btlx_2_1.value) >>> for processing in processings: >>> code = mc.get_processing_code(element, processing) Returns: The processing code. """ ``` -------------------------------- ### Get Processing Name Example Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/release_notes.md Demonstrates how to retrieve the name of a processing for a given element and processing ID. This example iterates through BTL processings and fetches their names. ```python def get_processing_name(reference_element_id: int, processing_id: int) -> str: """Get the name of a processing. Parameters: reference_element_id: The reference element ID. processing_id: The processing ID. Examples: >>> import cadwork >>> import element_controller as ec >>> import machine_controller as mc >>> element: int = 123456789 >>> processings = mc.get_element_btl_processings(element, cadwork.btl_version.btlx_2_1.value) >>> for processing in processings: >>> name = mc.get_processing_name(element, processing) Returns: The processing name. """ ``` -------------------------------- ### Get Processing BTL Parameter Set Example Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/release_notes.md Demonstrates how to retrieve the BTL parameter set for a processing, given the element and processing ID. This example iterates through BTL processings and fetches their parameters. ```python def get_processing_btl_parameter_set(reference_element_id: int, processing_id: int) -> List[str]: """Get the BTL parameter set for a processing. Parameters: reference_element_id: The reference element ID. processing_id: The processing ID. Examples: >>> import cadwork >>> import element_controller as ec >>> import machine_controller as mc >>> element: int = 123456789 >>> processings = mc.get_element_btl_processings(element, cadwork.btl_version.btlx_2_1.value) >>> for processing in processings: >>> parameters = mc.get_processing_btl_parameter_set(element, processing) Returns: List of BTL parameter strings. """ ``` -------------------------------- ### Element Controller Example Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/documentation/element_controller.md Demonstrates the basic structure and usage of the Element Controller. ```python from cw_api.element_controller import ElementController # Assuming you have an initialized API client # api_client = CWAPIClient() # Initialize the Element Controller # element_controller = ElementController(api_client) # Example usage (replace with actual methods) # elements = element_controller.get_elements() # print(elements) ``` -------------------------------- ### Open File and Select Version with /EXE= Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/command_line.md Use the `/EXE=` argument to specify which installed cadwork version should open a given `.3d` file. This is useful when multiple versions are installed. ```powershell D:\cadwork.dir\ci_start.exe "C:\Users\Me\Downloads\timber-framed-elements.3d" /EXE=D:\cadwork.dir\exe_2026 ``` ```powershell Start-Process "C:\Users\Me\Downloads\timber-framed-elements_2027.3d" -ArgumentList '/EXE=D:\cadwork.dir\exe_2027' ``` -------------------------------- ### Dimension Controller Example Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/documentation/dimension_controller.md Demonstrates how to use the Dimension Controller to interact with dimensions. This snippet requires the DimensionController class to be imported. ```python from cw_api.dimension_controller import DimensionController dc = DimensionController() # Example usage (replace with actual methods) dc.get_dimensions() dc.set_dimension("width", 100) dc.get_dimension("height") ``` -------------------------------- ### Multi Layer Cover Controller Example Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/documentation/multi_layer_cover_controller.md Demonstrates the basic usage of the Multi Layer Cover Controller. This snippet is intended for general understanding and integration. ```python from cw_api.cwapi3d.controllers.multi_layer_cover_controller import MultiLayerCoverController # Assuming 'api' is an initialized CWAPI3D instance controller = MultiLayerCoverController(api=api) # Example usage (replace with actual parameters) # result = controller.some_method(param1, param2) # print(result) print("MultiLayerCoverController initialized and ready.") ``` -------------------------------- ### BIMteam Upload Result Code Examples Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/documentation/bim_team_upload_result.md Provides code examples for interacting with BIMteam upload results. These snippets demonstrate how to use the upload result objects in Python. ```python from cadwork import bim_team_upload_result_code # Assuming 'upload_result_code' is an instance of bim_team_upload_result_code # Example usage: # print(upload_result_code.id) # print(upload_result_code.status) # print(upload_result_code.message) # print(upload_result_code.data) ``` -------------------------------- ### PyQt5 Window with Button Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/tk_gui.md A simple PyQt5 application creating a basic window with a button. This example demonstrates the fundamental structure for building GUI applications using PyQt5. ```python from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton, QApplication, QLabel) class MyWindow(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): btn = QPushButton('Button', self) btn.resize(btn.sizeHint()) btn.move(50, 50) self.setGeometry(300, 300, 300, 200) self.setWindowTitle('Qt5 Button') if __name__ == '__main__': window = MyWindow() window.show() ``` -------------------------------- ### Install Specific Version of CWAPI3D Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/get_started.md Install a specific version of the CWAPI3D package by specifying the package name and version. ```bash pip install == ``` -------------------------------- ### Locate ci_start.exe Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/command_line.md The cadwork launcher `ci_start.exe` is located in your `cadwork.dir` folder. Each installed version has a corresponding `exe_` subfolder. ```text ...\cadwork.dir\ci_start.exe ``` ```text ...\cadwork.dir\exe_2026 ...\cadwork.dir\exe_2027 ``` -------------------------------- ### Get User Input for Drilling Creation Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/utility_example.md This snippet shows how to interact with the user to get boolean confirmation, a 3D point, and a double value for creating a drilling element. It uses utility functions to prompt the user. ```python import cadwork import utility_controller as uc import element_controller as ec drill_bool = uc.get_user_bool("Do u want to create a drilling ?", True) if drill_bool: pt = uc.get_user_point() length = uc.get_user_double('Enter the drilling length') drilling = ec.create_drilling_vectors(40, length, pt, cadwork.point_3d(0., 0., -1.)) ``` -------------------------------- ### Tkinter Button Widget Example Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/tk_gui.md Demonstrates the creation and basic functionality of a tkinter Button widget. The button is configured with text and a command to execute when clicked. ```python import tkinter as tk class MyApp(tk.Frame): def __init__(self, master=None): super().__init__(master) self.pack() self.ok = tk.Button(self) self.ok["text"] = "cadwork" self.ok["command"] = self.handler self.ok.pack() def handler(self): print("Button clicked") if __name__ == "__main__": root = tk.Tk() root.geometry("500x300") app = MyApp(root) app.mainloop() ``` -------------------------------- ### Install cwapi3d with pip Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/README.md Install the Cadwork Python Interface library using pip. This is the standard method for adding the library to your Python environment. ```bash pip install cwapi3d ``` -------------------------------- ### Create Square Beam with Vectors Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/element_example.md Creates a square beam using specified dimensions, a starting point, and direction vectors. ```python import cadwork import element_controller as ec point = cadwork.point_3d(100, 200, 300) vector_x = cadwork.point_3d(1., 0., 0.) vector_z = cadwork.point_3d(0., 0., 1.) width = 200. length = 2600. beam = ec.create_square_beam_vectors(width, length, point, vector_x, vector_z) ``` -------------------------------- ### Importing the 3D Point Module Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/documentation/point_3d.md Import the `point_3d` module from the `cadwork` library to start working with 3D points. ```python from cadwork import point_3d ``` -------------------------------- ### Tkinter Hello World Application Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/tk_gui.md A basic tkinter application demonstrating a 'Hello World' button and a quit button. This serves as a starting point for creating GUI applications with tkinter. ```python import tkinter as tk class Application(tk.Frame): def __init__(self, master=None): super().__init__(master) self.master = master self.pack() self.create_widgets() def create_widgets(self): self.hi_there = tk.Button(self) self.hi_there["text"] = "Hello cadwork World\n(click me)" self.hi_there["command"] = self.say_hi self.hi_there.pack(side="top") self.quit = tk.Button(self, text="QUIT", fg="blue", command=self.master.destroy) self.quit.pack(side="bottom") def say_hi(self): print("hi there, everyone!") root = tk.Tk() app = Application(master=root) app.mainloop() ``` -------------------------------- ### Remote Debugging Setup with PyCharm Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/debug.md Integrate PyCharm's remote debugger into your Python script to debug code running on a remote machine. Ensure the pydevd-pycharm package is installed on the remote host and the trace is set with the correct IP address and port. ```python import math # ==============this code added==================================================================: import pydevd_pycharm pydevd_pycharm.settrace('172.20.208.95', port=12345, stdoutToServer=True, stderrToServer=True) # ================================================================================================ class Solver: def demo(self, a, b, c): d = b ** 2 - 4 * a * c if d > 0: disc = math.sqrt(d) root1 = (-b + disc) / (2 * a) root2 = (-b - disc) / (2 * a) return root1, root2 elif d == 0: return -b / (2 * a) else: return "This equation has no roots" if __name__ == '__main__': solver = Solver() while True: a = int(input("a: ")) b = int(input("b: ")) c = int(input("c: ")) result = solver.demo(a, b, c) print(result) ``` -------------------------------- ### Batch Processing with PowerShell Loop Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/command_line.md Automate processing of multiple files in a folder using a PowerShell loop. This example opens each `.3d` file with a specific cadwork version and runs an export plugin. ```powershell $exe = 'D:\cadwork.dir\ci_start.exe' $exeDir = 'D:\cadwork.dir\exe_2026' $files = Get-ChildItem 'C:\Projects\Batch' -Filter *.3d foreach ($file in $files) { Write-Host "Processing $($file.Name)" Start-Process -FilePath $exe ` -ArgumentList "`"$($file.FullName)`"", "/EXE=$exeDir", '/PLUGIN=MyExportScript' ` -Wait } ``` -------------------------------- ### Get GlobalId (IfcGuid) Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/bim_example.md Retrieves the IFC GUID for active elements. Requires importing cadwork, bim_controller, and element_controller. ```python import cadwork import bim_controller as bc import element_controller as ec # get active element_ids element_ids = ec.get_active_identifiable_element_ids() for element_id in element_ids: guid = bc.get_ifc_guid(element_id) print(guid) ``` -------------------------------- ### Get Building and Storey Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/bim_example.md Retrieves the building and storey names for active elements. Requires importing cadwork, bim_controller, and element_controller. ```python import cadwork import bim_controller as bc import element_controller as ec # get active element_ids element_ids = ec.get_active_identifiable_element_ids() for element_id in element_ids: bc.get_building(element_id) storey_name = bc.get_storey(element_id) ``` -------------------------------- ### Get Storey Height Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/bim_example.md Calculates and prints the height of a storey for a given building. Requires importing cadwork, bim_controller, and element_controller. ```python import cadwork import bim_controller as bc import element_controller as ec # get active element_ids element_ids = ec.get_active_identifiable_element_ids() for element_id in element_ids: building_name = bc.get_building(element_id) storey_name = bc.get_storey(element_id) storey_height = bc.get_storey_height(building_name, storey_name) print(storey_height) ``` -------------------------------- ### Get User Attributes Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/attribute_example.md Retrieves user-defined attribute values and names for active elements based on their ID and attribute number. Also fetches the element's GUID. Requires `attribute_controller` and `element_controller` modules. ```python import attribute_controller as ac # import module import element_controller as ec # get active element_ids element_ids = ec.get_active_identifiable_element_ids() for element_id in element_ids: user_attr = ac.get_user_attribute(element_id, 20) # 20 = attribute number user_attr_name = ac.get_user_attribute_name(20) element_guid = ec.get_element_cadwork_guid(element_id) print(user_a_name, user_a, element_guid ) ``` -------------------------------- ### Hello Cadwork API Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/index.md A simple Python script to print a greeting message. This is a basic starting point for interacting with the Cadwork API. ```python print("Hello Cadwork! Let's get started!") ``` -------------------------------- ### Get Material IDs and Names Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/material_example.md Iterates through all available materials to fetch their IDs and names, storing them in a dictionary. Requires the 'cadwork' and 'material_controller' modules. ```python import cadwork import material_controller as mc material_ids_by_name = {} for material_id in mc.get_all_materials(): mat_name = mc.get_name(material_id) material_ids_by_name[mat_name] = material_id ``` -------------------------------- ### Main Function - Element Processing and Menu Interaction Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/menu_example.md The main function orchestrates the process of getting active elements, determining their types, and updating their output types based on user menu selection. It includes logic for hiding/showing elements, zooming, and printing errors. Ensure that `ec.get_active_identifiable_element_ids`, `ac.get_element_type`, `list_ele_types`, `ac.get_output_type`, `vc.hide_all_elements`, `vc.set_visible`, `vc.zoom_all_elements`, `uc.print_error`, `menu_output_type`, `list_process_types_set`, `ac.set_output_type`, and `list_process_types_is` are correctly implemented and imported. ```python def main(): active_elements = ec.get_active_identifiable_element_ids() if len(active_elements) > 0: for element in active_elements: ele_type = ac.get_element_type(element) l_ele_types = list_ele_types(ele_type) process_type = ac.get_output_type(element) l_process_types = list_process_types_is(process_type) for p_type in l_process_types: if p_type[0]: for e_type in l_ele_types: if e_type[0]: vc.hide_all_elements() vc.set_visible([element]) vc.zoom_all_elements() uc.print_error(f'Elementyp = {e_type[1]} / Ausgabeart = {p_type[1]}') n_process_type = list_process_types_set(menu_output_type(), process_type) ac.set_output_type([element], n_process_type) l_process_types = list_process_types_is(process_type) for p_type_n in l_process_types: if p_type_n[0]: uc.print_error(f'Ausgabeart neu = {p_type_n[1]}') if __name__ == '__main__': main() ``` -------------------------------- ### Get Beam Points and Vectors Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/geometry_example.md Retrieves local vectors (x, y, z) and Cartesian points (p1, p2, p3) for active elements. Useful for detailed geometric analysis of beam elements. ```python import cadwork import element_controller as ec import geometry_controller as gc # get active element_ids element_ids = ec.get_active_identifiable_element_ids() for element_id in element_ids: vector_x = gc.get_xl(element_id) # returns local vector vector_y = gc.get_yl(element_id) # returns local vector vector_z = gc.get_zl(element_id) # returns local vector get_p1 = gc.get_p1(element_id) # returns cartesian point get_p2 = gc.get_p2(element_id) # returns cartesian point get_p3 = gc.get_p3(element_id) # returns cartesian point print(f"""the elements local vecotr z is: {vector_z} \n' the coordinates of the point_3 are {get_p3}""") ``` -------------------------------- ### Get Elements from Scene Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/scene_example.md Retrieves all element IDs from a specified scene and prints the count of elements and a set of their subgroups. This is useful for inspecting the contents of a scene. ```python element_ids_scene = sc.get_elements_from_scene('NewScene') element_subgroup_scene = [] for element_id in element_ids_scene: group = ac.get_group(element_id) element_subgroup_scene.append(group) print(len(element_ids_scene)) print(set(element_subgroup_scene)) ``` -------------------------------- ### Run Plugin from Console Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/get_started.md Use the /PLUGIN= flag with ci_start.exe to launch a specific plugin. Replace 'test' with the actual plugin name you wish to run. ```cmd ...\cadwork.dir\ci_start.exe "C:\...\myFile.3d" /PLUGIN=test ``` -------------------------------- ### Create and Display a Simple Menu Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/menu_example.md Use this to create a basic menu with options and handle user selections. The loop continues until the 'Return' option is chosen. ```python import menu_controller as mec import utility_controller as uc import cadwork menu_options = 'Foo', 'Bar', 'Baz', '', 'Return' while True: menu = mec.display_simple_menu(menu_options) if menu == 'Foo': uc.print_error('You pressed Foo') elif menu == 'Bar': uc.print_error('You pressed Bar') elif menu == 'Baz': uc.print_error('You pressed Baz') elif menu == 'Return': break ``` -------------------------------- ### Get Endtype Name at Start Point Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/endtype_example.md Retrieves and prints the end type name for each active element. Requires importing cadwork, endtype_controller, and element_controller. ```python import cadwork # import module import endtype_controller as etc import element_controller as ec element_ids = ec.get_active_identifiable_element_ids() for element_id in element_ids: endtype_name = etc.get_endtype_name_start(element_id) print(endtype_name) ``` -------------------------------- ### Other Useful Command-Line Arguments Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/command_line.md Provides a list of additional command-line arguments for managing licenses, user profiles, catalogs, and working directories. ```text /GET_LICENCE /USP /CATDIR /WORKDIR ``` -------------------------------- ### Create New Material and Assign Group Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/material_example.md Demonstrates creating a new material with a specified name and then assigning it to a group. Uses the 'material_controller' module. ```python import material_controller as mc material_id = mc.create_material('Cross-Laminated-Timber') # the new created material is stored in the category "No groups" mc.set_group(material_id, 'Plattenwerkstoffe') # the new created material is now shifted in the category "Plattenwerkstoffe" ``` -------------------------------- ### Export Rhino File - Create Directory Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/file_example.md Demonstrates how to create a directory before exporting a Rhino file, ensuring the target path exists. It includes error handling for cases where the directory already exists. ```APIDOC ## export_rhino_file (with directory creation) ### Description Exports selected elements to a Rhino file format after ensuring the target directory exists. Includes error handling for directory creation. ### Parameters - **element_ids** (list) - Required - A list of element IDs to export. - **file_name** (str) - Required - The full path including the filename where the Rhino file will be saved. - **version** (int) - Required - The version of the Rhino file to export. - **use_default_assignment** (bool) - Required - Whether to use default assignments. - **write_standard_attributes** (bool) - Required - Whether to write standard attributes. ### Notes This example also shows the use of `os.mkdir` for directory creation and `FileExistsError` handling. ``` -------------------------------- ### Import Step File Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/file_example.md Imports a Step file (.stp) with an option for messages. Requires the file path, a scale factor, and a boolean for message options. ```python import file_controller as fc # import module import element_controller as ec import_file = uc.get_new_user_file_from_dialog("*.stp") # str: aFilePath, float: aScale, bool: aMesageOption fc.import_step_file_with_message_option(import_file, 0.0001, True) ``` -------------------------------- ### Compare Strings Lexicographically Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/compare.md Demonstrates various string comparison operations including equality, less than, greater than, and not equal. Case sensitivity affects the outcome. ```python if __name__ == '__main__': print("cadwork" == "cadwork") print("Cadwork" < "cadwork") print("Cadwork" > "cadwork") print("cadwork" != "cadwork") #output # True # True # False # False ``` -------------------------------- ### Import Standard Python Modules Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/modules.md Demonstrates importing common standard Python modules like math, csv, and tkinter alongside the cadwork module. ```python # import modules import cadwork import math import csv import tkinter ... ``` -------------------------------- ### Create and Add Elements to Scene Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/scene_example.md Creates a new scene and adds currently active elements to it. The new scene is then activated. ```python import element_controller as ec import cadwork import scene_controller as sc element_ids = ec.get_active_identifiable_element_ids() new_scene = sc.add_scene('NewScene') if new_scene: sc.add_elements_to_scene('NewScene', element_ids) sc.activate_scene('NewScene') ``` -------------------------------- ### Get BTL Processing IDs for an Element Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/release_notes.md Retrieves a list of BTL processing IDs associated with a specific element. Requires the element ID and the BTL version. ```python def get_element_btl_processings(element_id: int, btl_version: int) -> List[int]: """Get BTL processing IDs for an element. Parameters: element_id: The element ID. btl_version: The BTL version. Returns: List of processing IDs. """ ``` -------------------------------- ### Get Hundegger Processing IDs for an Element Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/release_notes.md Retrieves a list of Hundegger processing IDs associated with a specific element. Requires the element ID and the Hundegger type. ```python def get_element_hundegger_processings(element_id: int, hundeggertype: int) -> List[int]: """Get Hundegger processing IDs for an element. Parameters: element_id: The element ID. hundeggertype: The Hundegger type. Returns: List of processing IDs. """ ``` -------------------------------- ### Import Step File Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/file_example.md Imports a STEP file into the current project. This function requires the file path, a scale factor, and a boolean option to control messages. ```APIDOC ## import_step_file_with_message_option ### Description Imports a STEP file into the current project with specified options. ### Parameters - **aFilePath** (str) - Required - The path to the STEP file to import. - **aScale** (float) - Required - The scale factor to apply during import. - **aMesageOption** (bool) - Required - A boolean option to control messages during import. ``` -------------------------------- ### Import cadwork.extended_settings Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/documentation/extended_settings.md Import the extended_settings module from the cadwork library. This is typically the first step before using any of its functionalities. ```python from cadwork import extended_settings ``` -------------------------------- ### Import Attribute Display Settings Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/documentation/attribute_display_settings.md Import the attribute_display_settings module from the cadwork library. ```python from cadwork import attribute_display_settings ``` -------------------------------- ### Set Elements to Immutable Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/visualization_example.md Gets the IDs of currently active elements and allows the user to set them as immutable using the visualization controller. Requires importing cadwork, element_controller, and visualization_controller. ```python import cadwork import element_controller as ec import visualization_controller as vc element_ids = ec.get_active_identifiable_element_ids() immutable = uc.get_user_bool("Do you want to set the elements to immutable ?", True) if immutable: vc.set_immutable(element_ids) ``` -------------------------------- ### Create a Cadwork 3D Point Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/cadwork.md Demonstrates how to create a 3D point in Cadwork using its x, y, and z coordinates. Ensure the cadwork module is imported. ```python import cadwork # import module point = cadwork.point_3d(100, 200, 300) # create a cadwork Point ``` -------------------------------- ### Batch Printing/Exporting .2d Files Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/command_line.md Print plotter or laser frames directly from the command line for `.2d` files. Specify frame ranges or types for printing. ```cmd ci_start.exe "C:\path\plan.2d" /P A :: print all plotter frames to the default plotter ``` ```cmd ci_start.exe "C:\path\plan.2d" /P 1-2;5;7 :: print plotter frames 1, 2, 5, 7 (and following) ``` ```cmd ci_start.exe "C:\path\plan.2d" /L A :: print all laser frames to the default laser ``` ```cmd ci_start.exe "C:\path\plan.2d" /L PDF :: print all laser frames to the default PDF driver ``` -------------------------------- ### Verify Gemini CLI MCP Connection Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/mcp.md List the currently configured MCP servers in the Gemini CLI to verify the connection. ```bash gemini mcp list ``` -------------------------------- ### Concatenate Group and Length Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/auto_attributes.md This script concatenates the group and component length of elements, rounding the length to 4 decimal digits. It retrieves element IDs, then iterates to get and format the group and length before setting the auto-attribute. ```python import cadwork import attribute_controller import geometry_controller element_ids = cadwork.get_auto_attribute_elements()#gets the specified element for element_id in element_ids: length = geometry_controller.get_length(element_id) group = attribute_controller.get_group(element_id) result = ' Group:' + group + 'Length:' + str(length) cadwork.set_auto_attribute([element_id], result)#sets the attribute ``` -------------------------------- ### Set Endtype Name at Start Point Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/endtype_example.md Replaces a specific end type ('V_8') with a user-defined new end type for active elements. It counts and reports the number of replacements made. Requires importing cadwork, endtype_controller, element_controller, and utility_controller. ```python import cadwork # import module import endtype_controller as etc import element_controller as ec import utility_controller as uc element_ids = ec.get_active_identifiable_element_ids() new_endtype = uc.get_user_string("name of the new end-type") i = 0 for element_id in element_ids: endtype_name = etc.get_endtype_name_start(element_id) if endtype_name == "V_8": # V_8 = name of an endtpye etc.set_endtype_name_start(element_id, new_endtype) i += 1 uc.print_error("Number of end-type replaced:%d" % i) ``` -------------------------------- ### Export Part List Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/list_example.md Exports a list of part information for the currently active identifiable elements to a specified file path. Ensure the file path is valid. ```python import cadwork import list_controller as lc import utility_controller as uc import visualization_controller as vc element_ids = ec.get_active_identifiable_element_ids() lc.export_part_list(element_ids, 'C:\\Downloads\\api_list.cwlm') ``` -------------------------------- ### Auto-run Python Script with /PLUGIN= Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/command_line.md The `/PLUGIN=` argument automatically executes a Python script after the file opens. The script name corresponds to the plugin folder name in your `API.x64` directory. ```cmd ...\cadwork.dir\ci_start.exe "C:\path\to\myFile.3d" /PLUGIN=MyScript ``` -------------------------------- ### Create Node with Cadwork Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/element_example.md Creates a basic 3D node using cadwork.point_3d and the element_controller.create_node function. ```python import cadwork import element_controller as ec point = cadwork.point_3d(100, 200, 300) node = ec.create_node(point) ``` -------------------------------- ### Overview of point_3d Methods Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/geometry.md Lists the available arithmetic and utility methods for the cadwork point_3d object, including vector operations and property calculations. ```python point_3d + point_3d point_3d - point_3d point_3d * float point_3d / float point_3d += point_3d point_3d -= point_3d point_3d *= float point_3d /= float -point_3d point_3d == point_3d point_3d != point_3d point_3d.dot(point_3d) # dot product or scalar product point_3d.cross(point_3d) # cross product or vector product point_3d.magnitude() # vector magnitude or length point_3d.normalized() # a normalized vector maintains its direction but its length becomes 1 point_3d.distance(point_3d) # distance between two points ``` -------------------------------- ### Append Path and Import External Module Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/modules.md Shows how to add a custom directory to sys.path to enable importing external modules. This is useful when external packages are not in the default search paths. ```python # import modules import sys import utility_controller as uc # get userprofil path USERPROFIL = uc.get_3d_userprofil_path() # appending a path sys.path.append(USERPROFIL + '\\api.x64\\FolderName\\PackageFolder') # printing all paths print(sys.path) # import external modules import PackageFolder ``` -------------------------------- ### Import 3DC Options Module Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/documentation/import_3dc_options.md Import the `import_3dc_options` module from the `cadwork` library. This is the primary entry point for using 3DC import functionalities. ```python import cadwork.import_3dc_options ``` -------------------------------- ### Set Building and Storey Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/bim_example.md Assigns active elements to a specific building and storey. Requires importing cadwork, bim_controller, and element_controller. ```python import cadwork import bim_controller as bc import element_controller as ec # get active element_ids element_ids = ec.get_active_identifiable_element_ids() bc.set_building_and_storey([element_ids], 'BuildingName', 'Level_1') ``` -------------------------------- ### Create Surface from Element Facets Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/element_example.md Creates a surface for each facet of the active elements. Requires geometry_controller. ```python import cadwork import geometry_controller as gc import element_controller as ec element_ids = ec.get_active_identifiable_element_ids() for element_id in element_ids: facets = gc.get_element_facets(element_id) for facet in facets: ec.create_surface(facet) ``` -------------------------------- ### Tkinter Entry Widget with Variable Coupling Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/tk_gui.md Shows how to couple a tkinter Entry widget with a StringVar. Changes in the entry widget update the variable, and vice versa. Includes a key binding to print the entry's content. ```python import tkinter as tk class App(tk.Frame): def __init__(self, master): super().__init__(master) self.pack() self.entrythingy = tk.Entry() self.entrythingy.pack() # Create the application variable. self.contents = tk.StringVar() # Set it to some value. self.contents.set("this is a variable") # Tell the entry widget to watch this variable. self.entrythingy["textvariable"] = self.contents # Define a callback for when the user hits return. # It prints the current value of the variable. self.entrythingy.bind('', self.print_contents) def print_contents(self, event): print("Hi. The current entry content is:", self.contents.get()) root = tk.Tk() myapp = App(root) myapp.mainloop() ``` -------------------------------- ### Accessing Point Coordinates by Index Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/geometry.md Demonstrates how to access the x, y, and z coordinates of a cadwork point_3d object using list-like indexing. ```python import cadwork # import module point = cadwork.point_3d(100, 200, 300) # create a cadwork Point print(point[0]) # prints x coordinate print(point[1]) # prints y coordinate print(point[2]) # prints z coordinate ``` -------------------------------- ### create_surface Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/element_example.md Creates a surface from the facets of a given element. ```APIDOC ## create_surface ### Description Creates a surface from the facets of a given element. ### Method `ec.create_surface(facet: any) -> int` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import cadwork import geometry_controller as gc import element_controller as ec element_ids = ec.get_active_identifiable_element_ids() for element_id in element_ids: facets = gc.get_element_facets(element_id) for facet in facets: ec.create_surface(facet) ``` ### Response #### Success Response (200) - **surface_id** (int) - The ID of the newly created surface. #### Response Example ```json { "surface_id": 67890 } ``` ``` -------------------------------- ### Set IFC Wall Type for Rough Volume Framed Walls Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/cadwork.md Processes active elements, checks if they are rough volume framed walls based on their output type, and sets their IFC type to 'IfcWall'. Requires importing cadwork, attribute_controller, bim_controller, and element_controller. ```python import cadwork # import module import attribute_controller as ac import bim_controller as bc import element_controller as ec element_ids = ec.get_active_identifiable_element_ids() for element_id in element_ids: output_type = ac.get_output_type(element_id) ifc_type = bc.get_ifc2x3_element_type(element_id) if cadwork.process_type.is_rough_volume_framed_wall(output_type): ifc_type.set_ifc_wall() bc.set_ifc2x3_element_type([element_id], ifc_type) ``` -------------------------------- ### Import Element Module Properties Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/documentation/element_module_properties.md Import the element_module_properties module to access its functionalities. ```python from cadwork.element_module_properties import * ``` -------------------------------- ### Run Python Script in cadwork Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/get_started.md This script demonstrates how to import necessary cadwork modules, retrieve active element IDs, and print their subgroups. Ensure you have the cadwork, element_controller, and attribute_controller modules available. ```python # import modules import cadwork import element_controller as ec import attribute_controller as ac # get active element_ids element_ids = ec.get_active_identifiable_element_ids() for element_id in element_ids: subgroup = ac.get_subgroup(element_id) # get subgroup name of active element_ids print(subgroup) # print the subgroup names ``` -------------------------------- ### Add MCP Server to Gemini CLI Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/mcp.md Configure the Gemini CLI to connect to the Cadwork Python MCP server. ```bash npm install -g @google/gemini-cli@latest ``` ```bash gemini mcp add --transport http cadwork-pyapi https://pyapi.mcp.cadwork.dev/mcp ``` -------------------------------- ### Configure MCP Server for VS Code (GitHub Copilot) Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/mcp.md Add the Cadwork Python MCP server configuration to your VS Code settings file. ```json { "servers": { "cadwork-pyapi": { "type": "http", "url": "https://pyapi.mcp.cadwork.dev/mcp" } } } ``` -------------------------------- ### Assign Color to Beam Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/visualization_example.md Creates a square beam using element controller and assigns a specific color to it using the visualization controller. Requires importing cadwork, element_controller, and visualization_controller. ```python import cadwork import element_controller as ec import visualization_controller as vc point = cadwork.point_3d(100, 200, 300) vector_x = cadwork.point_3d(1., 0., 0.) vector_z = cadwork.point_3d(0., 0., 1.) width = 200. length = 2600. color = 3 beam = ec.create_square_beam_vectors(width, length, point, vector_x, vector_z) add_beam_color = vc.set_color([beam], color) ``` -------------------------------- ### Menu Output Type Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/menu_example.md This function displays a simple menu of process type options to the user and returns the selected option's index plus one. It relies on an external `mc.display_simple_menu` function to render the menu and capture user input. The returned value is intended to be used with `list_process_types_set`. ```python def menu_output_type(): menu_items = ['hip_valley', 'jack_rafter', 'log', 'none', 'panel_1', 'panel_2', 'panel_3', 'panel_4', 'panel_5', 'purlin', 'rafter', 'rough_volume_framed_wall', 'rough_volume_log_home', 'rough_volume_solid_wood_wall', 'stud', 'tread', 'truss', 'user_1', 'user_2', 'user_3', 'user_4', 'user_5'] menu_select = mc.display_simple_menu(menu_items) menu_i = menu_items.index(menu_select) return menu_i+1 ``` -------------------------------- ### Compare Custom Objects (Value vs. Entity) Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/compare.md Compares custom objects by implementing the `__eq__` method. For entity objects, comparison is based on a unique identifier (passport_id) and requires implementing `__hash__`. ```python import dataclasses # value class @dataclasses.dataclass() class Address: street: str number: int zipcode: int def __eq__(self, other): if not isinstance(other, Address): return False return self.street == other.street \ and self.number == other.number \ and self.zipcode == other.zipcode # entity class class Person: def __init__(self, name, passport_id, address): self.name: str = name self.address: Address = address self.passport_id: int = passport_id def __eq__(self, other): if not isinstance(other, Person): return False return self.passport_id == other.passport_id def __hash__(self): return hash(self.passport_id) if __name__ == '__main__': address1 = Address(street="ThisStreet", number=20, zipcode=8084) address2 = Address(street="OtherStreet", number=204, zipcode=9000) print(address1 == address2) person1 = Person(name="John", passport_id=123456, address=address1) person2 = Person(name="John", passport_id=123456, address=address2) print(person1 == person2) print(person1.__hash__() == person2.__hash__()) ``` -------------------------------- ### Moving a cadwork Point Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/geometry.md Illustrates how to translate a cadwork point in 3D space by adding a scaled direction vector to it. ```python import cadwork # import module vector_x = cadwork.point_3d(1., 0., 0.) # define vector distance = 1500.0 # moving distance moved_point = point + (vector_x * distance) ``` -------------------------------- ### Create and Name a Beam Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/attribute_example.md Creates a square beam using specified dimensions and vectors, then assigns a name to it. Requires `cadwork`, `attribute_controller`, and `element_controller` modules. ```python import cadwork # import module import attribute_controller as ac import element_controller as ec point = cadwork.point_3d(100, 200, 300) # create a cadwork Point vector_x = cadwork.point_3d(1., 0., 0.) # x vector length direction vector_z = cadwork.point_3d(0., 0., 1.) # z vecotr height orientation width = 200. # width/heigth of beam section length = 2600. # beam length name = 'My first beam :)' # name as a string beam = ec.create_square_beam_vectors(width, length, point, vector_x, vector_z) # returns element_id add_beam_name = ac.set_name([beam], name) # input beam id (list), name (string) ``` -------------------------------- ### Export Rhino File with Directory Creation Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/file_example.md Exports selected elements to a Rhino file after ensuring the target directory exists. Handles FileExistsError if the directory is already present. ```python import file_controller as fc import element_controller as ec import os target_path = 'C:\\Users\\YourUsername\\Downloads\\RhinoExports\' try: create_direction = os.mkdir(target_path) # replace YourUsername with your username on your PC or add another directory # mkdir will create a folder with the Name RhinoExports except FileExistsError: # excepiton handling - if folder exists print("Folder already exists!") # path to the new file file_name = target_path + 'TestExport.3dm' element_ids = ec.get_active_identifiable_element_ids() fc.export_rhino_file(element_ids, file_name, 6, True, True) ``` -------------------------------- ### create_square_beam_vectors Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/element_example.md Creates a square beam with specified dimensions and orientation using vectors. ```APIDOC ## create_square_beam_vectors ### Description Creates a square beam with specified dimensions and orientation using vectors. ### Method `ec.create_square_beam_vectors(width: float, length: float, origin: cadwork.Point3D, direction_x: cadwork.Point3D, direction_z: cadwork.Point3D) -> int` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import cadwork import element_controller as ec point = cadwork.point_3d(100, 200, 300) vector_x = cadwork.point_3d(1., 0., 0.) vector_z = cadwork.point_3d(0., 0., 1.) width = 200. length = 2600. beam = ec.create_square_beam_vectors(width, length, point, vector_x, vector_z) ``` ### Response #### Success Response (200) - **beam** (int) - The ID of the newly created beam. #### Response Example ```json { "beam": 54321 } ``` ``` -------------------------------- ### Import cadwork Module Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/modules.md The cadwork module must be loaded into the namespace for many processes. This is a fundamental import. ```python import cadwork ``` -------------------------------- ### Export BTL Data Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/machine_example.md Exports data in BTL format. Specify the BTL version enumeration and the output file path. ```python import machine_controller as mac import cadwork btl_enum = 5 # VERSION: "BTL V10.6" # The enumeration is done according to the machine export listing in the export menu. file_path = 'C:\\Downloads\\api_btl.btl' mac.export_btl(btl_enum, file_path) ``` -------------------------------- ### Export Rhino File Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/file_example.md Exports selected elements to a Rhino file (.3dm). Requires element IDs, a file path, version, and assignment/attribute options. ```python import file_controller as fc # import module import element_controller as ec element_ids = ec.get_active_identifiable_element_ids() # list: aElementIdList, str: aFilePath, int: aVersion, bool: aUseDefaultAssignment, bool: aWriteStandardAttributes fc.export_rhino_file(element_ids, "C:\\Downloads\\RhinoExport.3dm", 6, True, True) ``` -------------------------------- ### BREP Vertex List Structure Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/documentation/brep_data.md Displays the structure of the vertex_list for BREP data. This is useful for understanding vertex representations and their coordinates. ```python from typing import List, Optional from pydantic import BaseModel class Vertex(BaseModel): coordinates: List[float] class VertexList(BaseModel): vertices: List[Vertex] parent_face: Optional[int] = None ``` -------------------------------- ### Calculating the Cross Product of Two Vectors Source: https://github.com/cwapi3d/cwapi3dpython/blob/main/docs/examples/geometry.md Demonstrates the calculation of the cross product between two cadwork point_3d vectors, resulting in a vector perpendicular to both. ```python import cadwork a = cadwork.point_3d(1., 0., 0.) b = cadwork.point_3d(0., 1., 0.) ab = a.cross(b) # ab = [0.000000, 0.000000, 1.000000] ```