VvierA Posted October 7, 2012 Share Posted October 7, 2012 Hello, I am a beginner and to start with vectorscript I'd like to make a simple 2D path object. It should work like the standard Vectorworks polygon tool but the polygon should close automatically after creation. I succeeded to generate a new 'empty' 2d path object with no code yet and to integrate this new tool in my workspace. Although there is no code yet, I can draw a 2D polygon shape. The problem is: the shape is invisible. It shows no lines and no filling. I can select it by 'select all' and it is shown in the info palette but it is not possible to change the appearance to make it visible. Question: What code do I have to add to make the path visible respectively to make this 'generic' 2d path behave like the original 2d polygon tool? Kind regards VvierA Quote Link to comment
Miguel Barrera Posted October 7, 2012 Share Posted October 7, 2012 Get the path object, which will be a polygon, fromm the pio and create the polygon/polyline from the path vertex data returned. Note that the reason for having an empty object is that the path can be something other than just a polygon (i.e. an extrude along a path by adding a profile to the pio). Quote Link to comment
VvierA Posted October 7, 2012 Author Share Posted October 7, 2012 Thank you Miguel. If I understand you correctly I have to insert code that draws the lines. And I get the coordinates to draw the lines from the data that is returned by the vertex code. What confused me was an example I found at vectorlab (Example Nr. 9) http://www.vectorlab.info/index.php?title=Events#Example_9 It's actually an example to explain Object events but it uses the 2D Path object and so I tried it. There is lots of object event code inside but strangely I can not find any code for drawing lines or polygons in this script. So how does it work? Thanks again VvierA P.S. Strange enough the example does not work like it should. It should go 'into 2D Reshape mode on double click' but if I double click an instance of that object it goes into the 'edit path object profile' mode. Quote Link to comment
Miguel Barrera Posted October 8, 2012 Share Posted October 8, 2012 In a nutshell: { obtain a handle to the path polygon of the object } gPathHdl:= GetCustomObjectPath(gObjHdl); {Get polyline data} vtxTot:= GetVertNum(gPathHdl); ALLOCATE gPlineList[1..vtxTot]; FOR i:= 1 TO vtxTot DO BEGIN GetPolylineVertex(gPathHdl, i, gPlineList.ptX, gPlineList.ptY, gPlineList.vtx, gPlineList.rad); gPlineList.vis:= GetVertexVisibility(gPathHdl,i-1); END; ..... ..... DrawPolyline; Quote Link to comment
VvierA Posted October 8, 2012 Author Share Posted October 8, 2012 Thank you very much Miguel. In the meantime I examined the script of Example 9 and succeeded to make an alternative solution to generate a 2D path by duplicating the drawn vertex path (see code below). Anyway I am looking now for a way to automatically close the polygon. Do you know a way to 'access' the 'close'-Checkbox via Vectorscript? VvierA PROCEDURE 2dpath; VAR theEvent, theButton :LONGINT; result :BOOLEAN; objHand, recHand, wallHand, pathHand, dupeHand :HANDLE; objName :STRING; BEGIN IF GetCustomObjectInfo(objName, objHand, recHand, wallHand) THEN BEGIN pathHand := GetCustomObjectPath(objHand); dupeHand := CreateDuplicateObject(pathHand, objHand); END; END; Run(2dpath); Quote Link to comment
Miguel Barrera Posted October 10, 2012 Share Posted October 10, 2012 Have you tried: PROCEDURE SetPolyClosed(polyHandle:HANDLE; isClosed:BOOLEAN); PROCEDURE Example; VAR h :HANDLE; BEGIN h := FSActLayer; SetPolyClosed(h, (NOT IsPolyClosed(h))); END; RUN(Example); Quote Link to comment
VvierA Posted October 11, 2012 Author Share Posted October 11, 2012 @Miguel Fantastic. That's it. Works perfect. Thank you so much. VvierA 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.