Jump to content

Vectorscript to Python conversion


Recommended Posts

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

Link to comment
  • 3 weeks later...

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.

Link to comment
  • 1 month later...

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.

1115466441_ConvertfromFaces.thumb.jpg.17a817770f14c77b962e671dc00eb225.jpg

 

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

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...