There are too many words for me to understand the requirements.
So, in as few a words as possible, what are you trying to do ?
I want all primitives lying in X/Y plane and at the same Z level to be selected and copied to a new layer. Then I can select all on that layer and apply 'Join' to obtain closed contours for milling.
@David
One thing I discovered while trying to make the script work:
The attached file is a simple part fresh from opening a .STEP file into CB. The only modification I did is create a new layer (3d), select all surfaces and join them into a single object on that layer. This leaves all wireframe primitives on a separate layer and with more complex parts reduces the total number of primitives.
- If you select the circle as on the picture the properties panel shows its center at 0,0,0 and an active T-Matrix. The actual Z is +3mm and X/Y coordinates are not zero. The same applies to other circles and corner arcs. Lines are OK.
- If I do 'Select all' -> 'Transform' -> 'Align' and do the alignment (I use Center,Center,Top) now those elements, upon selection, show 'Identity' and true coordinates. Which means that during the alignment CB also brings them to 'Identity' (applies the transformation). After that the script makes a correct selection.
I am attaching the .cb file without modifications.