BillW Posted February 24, 2022 Share Posted February 24, 2022 Just give some idea on converting a Vectorscript palette script to Python. The code splits a polyline/polygon into seperate line segments or linked curve segments which will give some idea how to traverse polylines/polygons including holes. Hope the code is useful. I did find that the VS call IsPolyClosed(polyH) is unreliable when you have invisible segments other than the last and doesnt handle holes so I wrote my own "IsClosed" I use a lot of STRUCTURE's in vectorscript which I have transposed into classes in python. Similarly there is no "repeat/until" in python which is handled by "while 1:" with a "break" call. Also vectorscript "case of" will have to wait for Python 3.10 version "match case" - use "if elif else" for the time being. Arrays such as "enddefs : array[1..250] of multidef;" are handled by a python class "multidef" and appended to a list via "enddefs.append(multidef(vstart,1))" Also note the use of GetEntityMatrix and SetEntityMatrix to align new content with the existing poly. Find enclosed text content of equivalent Vectorscript/Python code, a VW2020 file I used for testing with a script palette "Palette-1" and scripts "mark verts vs, split poly vs, split poly py" Been scripting for decades mostly in Vectorscript and mainly between my day job of 3D modelling. Lot's of relearning for Python needed. split spline test vw2020.vwx split poly vs.txt split poly py.txt 1 Quote Link to comment
PatW Posted February 25, 2022 Share Posted February 25, 2022 Just stumbled over the vs-py rosetta stone, in case you dont already know it: https://developer.vectorworks.net/index.php/User:CBM-c-/VS-Py_Rosetta_Stone Quote Link to comment
BillW Posted February 25, 2022 Author Share Posted February 25, 2022 Thanks PatW - duly bookmarked - just whats needed. Quote Link to comment
_c_ Posted March 13, 2022 Share Posted March 13, 2022 Hello, I am working on a brute force Pascal <> Python converter. This won't actually be much, but will provide a way to resolve the conversion of whole libraries. Not everything can be fixed though, and a lot of fixes still remain for making the code run properly. And let's not speak about optimising for Python. Quote Link to comment
BillW Posted May 4, 2022 Author Share Posted May 4, 2022 Following on from my initial post, thought I'd pass on an unencrypted full blown example of a python based menu command "Convert from Faces.." which places a symbol consisting of a 2D locus at locations around/on 2D/3D objects which can take account of adjacent 3D faces to determine direction. There's a lot of work with planar objects and vectors. I include an install file "install convertfromfaces.zip" which you can install in Vectorworks via Tools>Plugins Manager>Third-party Plug-ins>install... You will need to add command to a workspace via Tools>Workspaces...> Menus>WHW 3D modelling>Convert from Faces... The zip file contains the VSM file and supporting python files. As python files can't be uploaded, I include source code text files "convertfrom faces 2020", "convsf_classes" and "convsf_utils". Note, I use class convSF to store operational variables. Classes entmat, vertexdef and multidef are used to store geometry definitions. Displacement Offset works in local axes but Rotation works in world axes. Haven't figured out a local axes rotation yet. Hope this will pass on some inspiration. install convertfromfaces.zip convsf_classes source.txt convsf_utils source.txt convertfromfaces 2020 source.txt Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.