Syntax
texta=CPL2DXF([CPL,pcnt])
Input Parameter
CPL : | | CPL to convert into LWPOLYLINEs |
pcnt : | | already existing number of objects; default is 76 |
Output Parameter
texta : | | textstring for inserting into DXF file |
Examples
CPL2DXF(CPLsample(9),0)
CPL2DXF(CPLsample(9)) % first LWPOLYLINE command is missing
Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, CPL2DXF, is designed to convert a closed polygon list (CPL) into a DXF text format. The function is part of the SolidGeometry library and was introduced in version 5.0. Below is a detailed explanation of the algorithm and its parameters.
Input Parameters
- CPL: This is the primary input, representing a closed polygon list. If not provided, a default square polygon is used with dimensions 30x20 mm.
- pcnt: This is a counter used in relation to blocks in the CPLwriteDXF function. The default value is 76.
Output
- texta: This is the output text in DXF format, representing the input CPL.
Algorithm Steps
- The function starts by retrieving the CPL and pcnt parameters using the getfuncparams function. If not provided, default values are used.
- An empty string, texta, is initialized to store the resulting DXF text.
- The function separates the CPL into individual polygons using the separateNaN function, which counts the number of polygons (nc).
- For each polygon (k from 1 to nc), the following steps are executed:
- The current polygon CPLi is extracted using separateNaN.
- The number of vertices (n) in CPLi is determined.
- DXF header text (textA and textB) is prepared, including the LWPOLYLINE entity and other necessary DXF codes.
- DXF polyline text (text1 and text2) is prepared, specifying the number of vertices and other attributes.
- If k is 1 and pcnt is 76, text1 and text2 are combined directly. Otherwise, textA, textB, text1, and text2 are combined.
- For each vertex in CPLi, its coordinates are formatted and appended to the text.
- The complete text for the current polygon is appended to texta, prefixed by '0' to indicate a new entity.
- After processing all polygons, the initial '0' in texta is removed to finalize the output.
Algorithm explaination created using ChatGPT on 2025-08-19 08:03. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21