Gilbert Osmond Posted June 8, 2021 Share Posted June 8, 2021 (edited) How do I select a group of 2D or 3D loci and then create a polyline (or NURBS curve, if 3D) from them? I just want to select a group of properly-arranged 2D or 3D loci (i.e. they are all in a proper linear or curvilinear arrangement, there are no path crossovers or branches) and do something like "Create Line from Points..." but there is no such command? VW Designer 2021 SP3.1 Edited June 9, 2021 by Gilbert Osmond Quote Link to comment
Gilbert Osmond Posted June 9, 2021 Author Share Posted June 9, 2021 23 minutes ago, Boh said: I use the 3d polygon tool I know how to use the polygon tool to draw lines by hand. What I want to do is select a group of 3D loci (in this case, a roadway alignment from a survey I just imported) and have Vectorworks automatically connect all the points with a polyline or NURBS curve. If there was a menu command "Connect Points into Line..." I would use that but as far as I can see there is no such command or anything similar. Quote Link to comment
Jeff Prince Posted June 9, 2021 Share Posted June 9, 2021 @Gilbert Osmond I am unaware of a tool in Vectorworks that will do this for you. In AutoCAD, there was a 3rd party developer that created some tools to do so. So, I imagine such a tool could be made in Vectorworks using a script or other programming tool, maybe someone has already done this. Maybe @Pat Stanford knows of something? Perhaps check the Customization area of the forums. I could see where this would be handy when dealing with a bunch of points from a surveyor that did not include the centerline of the roadway 🙂 Quote Link to comment
Gilbert Osmond Posted June 9, 2021 Author Share Posted June 9, 2021 Maybe there's some plug-in or 3rd party script that will turn up to help me do this. As a CAD platform that aspires to be survey-ready I find it hard to believe that VW doesn't include this feature as part of its basic functionality. The very nature of survey work is point collection, and it's frequently thousands of points, many of them marking out non-rectilinear 2D features such as paths, roads, irregular garden beds, etc. I spent nearly 1.5 hours since I first posted this question here, laboriously clicking from point.. to point.. to point.. to point.. to point... with the Polyline tool.. to connect over 2,400 roadway survey points from raw survey data that were imported as 3D loci. Quote Link to comment
Jeff Prince Posted June 9, 2021 Share Posted June 9, 2021 Just out of curiosity, what program, other than survey specific processing tools, does this natively? Neither AutoCAD nor Civil 3D did this last I used them. I always had to go back to my surveyor and request them to process it for me. I believe they used Carlson or similar exported to DXF, Quote Link to comment
Gilbert Osmond Posted June 9, 2021 Author Share Posted June 9, 2021 Not sure if any do. I am not a licensed surveyor but I do a fair amount of informal surveying using GPS equipment to capture client landscapes. The workflow is easy -- shoot points, download a .CSV file of coordinates, import it into VW, and it's ready to use -- just need a way to connect dots semi-automatically to expedite linework. Quote Link to comment
Benson Shaw Posted June 9, 2021 Share Posted June 9, 2021 Not sure if this accomplishes anything desired, but ... The vwx site model (DTM) from 3d loci produces a point to point perimeter, plus the interior topography. If the raw data is somehow delimited, eg if provided with separate layers or classes for roads, beds , creeks, paths, etc, then a separate DTM for each will produce separate perimeters. and contour interval adjustments might be useful in some way for this -B 1 Quote Link to comment
Gilbert Osmond Posted June 9, 2021 Author Share Posted June 9, 2021 Just now, Benson Shaw said: Not sure if this accomplishes anything desired, but ... The vwx site model (DTM) from 3d loci produces a point to point perimeter, plus the interior topography. If the raw data is somehow delimited, eg if provided with separate layers or classes for roads, beds , creeks, paths, etc, then a separate DTM for each will produce separate perimeters. and contour interval adjustments might be useful in some way for this -B That's an interesting round-about way to achieve a similar result. I wonder if it would work for "1-dimensional" site models, i.e. where the "site model" is just a single line of points with no width (i.e. no cross-slope area.) Maybe I could use this to create 2D figures and then just convert the site model (in 2D plan view) to lines, and throw away the site model. Roundabout method... Quote Link to comment
Popular Post Jesse Cogswell Posted June 9, 2021 Popular Post Share Posted June 9, 2021 (edited) I could write a script that could pull in the XYZ locations of all selected loci and essentially use that data to "connect the dots" with a 3D polygon, but I think the biggest obstacle to making it work properly is that there is no real way to pull the order in which connect the loci. Calling a ForEachObject callback would be the most efficient, but it will follow in the order in which the loci were created with little regard to their physical location. Imagine you wanted to create a square with four loci, A (0,0), B (1,0), C (1,1), and D (0,1). There's no real easy way to tell the script to create a poly in A,B,C,D order, the script might create a poly in A,C,D,B order, resulting in an hourglass shape. Someone much smarter than me could probably write an algorithm to determine a clockwise or anti-clockwise path between a selection of points, but I can't think of an easy way off the top of my head without attaching a record to each loci with the poly creation order in it, but assigning that would take more time than drawing the polygon by hand. If you can assure that the points are created in the correct order, then the script below should do the trick. PROCEDURE CreatePolyFromPoints; {* Creates a 2D polygon from a selection of 2D Locus points and/or a 3D polygon from a selection of 3D Locus points Developed by: Jesse Cogswell Date: 6/8/2021 VW Version: 2019 *} VAR lociPoints:DYNARRAY[] OF POINT; lociPoints3D:DYNARRAY[] OF POINT3D; numPoints:INTEGER; currentLayer:STRING; finalPoly,finalPoly3D:HANDLE; deleteCheck:BOOLEAN; PROCEDURE PollThePoints(h:HANDLE); {Generates array of XY locations of selected points} VAR p1:POINT; BEGIN numPoints:=numPoints+1; ALLOCATE lociPoints[1..numPoints]; GetLocPt(h,p1.x,p1.y); lociPoints[numPoints]:=p1; IF(deleteCheck=TRUE) THEN DelObject(h); END; PROCEDURE PollThePoints3D(h:HANDLE); {Generates array of XYZ locations of selected 3D points} VAR p1:POINT3D; BEGIN numPoints:=numPoints+1; ALLOCATE lociPoints3D[1..numPoints]; Get3DCntr(h,p1.x,p1.y,p1.z); lociPoints3D[numPoints]:=p1; IF(deleteCheck=TRUE) THEN DelObject(h); END; FUNCTION CreatePolygon(points:DYNARRAY[] OF POINT; nPoints:INTEGER) : HANDLE; {Creates a polygon from given array of points and returns handle to polygon} VAR i:INTEGER; h:HANDLE; BEGIN ClosePoly; BeginPoly; FOR i:=1 TO nPoints DO AddPoint(points[i].x,points[i].y); EndPoly; CreatePolygon:=LNewObj; END; FUNCTION CreatePolygon3D(points:DYNARRAY[] OF POINT3D; nPoints:INTEGER) : HANDLE; {Creates a 3D polygon from given array of points and returns handle to polygon} VAR i:INTEGER; h:HANDLE; BEGIN CLosePoly; BeginPoly3D; FOR i:=1 TO nPoints DO Add3DPt(points[i].x,points[i].y,points[i].z); EndPoly3D; CreatePolygon3D:=LNewObj; END; BEGIN numPoints:=0; currentLayer:=GetLName(ActLayer); deleteCheck:=YNDialog('Delete Locus Points after creation?'); ForEachObject(PollThePoints,((SEL=TRUE) & (L=currentLayer) & (T=LOCUS))); IF(numPoints>1) THEN finalPoly:=CreatePolygon(lociPoints,numPoints); numPoints:=0; ForEachObject(PollThePoints3D,((SEL=TRUE) & (L=currentLayer) & (T=LOCUS3D))); IF(numPoints>1) THEN finalPoly3D:=CreatePolygon3D(lociPoints3D,numPoints); END; Run(CreatePolyFromPoints); The script will follow the points in the order of their creation and gives you an option to delete the locus points afterward. The script will handle 2D and 3D locus points and will generate accordingly, but separately. If you include a selection of 2D and 3D points, the script will generate a separate 2D and 3D polygon. Also keep in mind that it will be restricted to points on the active layer only to prevent it from misreading points still selected on a different layer (in case your Layer Options are set to Show/Snap). Let me know if this works for you or if this totally breaks something. It worked in my admittedly brief amount of testing on VW2019, but there's no reason it shouldn't work in VW2021. Edited June 9, 2021 by Jesse Cogswell 5 1 Quote Link to comment
Benson Shaw Posted June 9, 2021 Share Posted June 9, 2021 26 minutes ago, Gilbert Osmond said: Roundabout method... Totally roundabout. I was just playing with a work flow to extract the perimeter: Make the DTM, Edit Crop, Select/Copy the crop (a 2d poly), Exit. Paste in Place. Send to Surface. Result is a Group. Ungroup to reveal a 3d Poly following surface perimeter. The DTM has an algorithm to choose which source points are perimeter and which are interior topo, so all this probably doesn't meet the need. at least I can't make it do just a lasso selection of a curving line. Oh, well. 41 minutes ago, Jesse Cogswell said: an algorithm to determine a clockwise or anti-clockwise path Left to right, or screen upward/downward might also be needed if closed path is not desired (eg edge of roadway or path - it never connects to edge at the other side). But thanks for this script! -B Quote Link to comment
Jesse Cogswell Posted June 9, 2021 Share Posted June 9, 2021 I suppose I never asked if the polys wanted to be closed or not. If not, remove the lines with the ClosePoly; procedure and it will generate open polys. Doing a left to right or down to up sorting of the points wouldn't be terribly difficult, but I don't quite have time to add it right now. I'll see if I can get to it tomorrow night. Quote Link to comment
Gilbert Osmond Posted June 9, 2021 Author Share Posted June 9, 2021 1 hour ago, Jesse Cogswell said: I could write a script... ...Let me know if this works for you or if this totally breaks something. It worked in my admittedly brief amount of testing on VW2019, but there's no reason it shouldn't work in VW2021. I just added this to my Resources in VW Designer 2021. An initial test shows that it works pretty well. Thanks very much, learning to program with Vectorscript exceeds my time/attention budget for the forseeable future. 3 Quote Link to comment
Popular Post Jesse Cogswell Posted June 9, 2021 Popular Post Share Posted June 9, 2021 Glad to hear that this worked. If you don't need a closed poly, just remove the ClosePoly; lines. When I get some time, I can expand the tool a bit to open a dialog box to allow you to choose from a couple of different sorting options (left to right, top to bottom, creation order), to choose whether to close the poly, and whether to delete the source points and any number of other things you might need. Also, if you want to make this a permanent part of your VW workspace, follow the steps below. The advantage is that the tool is always available regardless of drawing, the downside is if you want to share with a team then you have to share the plug-in versus any one having the drawing having access to it. Click Tools - Plug-ins - Plug-in Manager Click the New button Name the plug-in something like "Create Poly From Points" Select the Command radio button (should be selected by default) Click OK Select the new command and click on the Edit Definition button In the General tab, assign a category. By default this will be "Miscellaneous," I put all my tools in a "JNC" category. This will be important later. In the Properties tab, check the "Object Selected" radio button for "Require". Nothing will happen if you run the tool with nothing selected, but this option will actively gray it out in the menu if nothing is selected. Add in a Tooltip Help if it pleases you. Not a bad idea if you're sharing the tool with a team. Click OK Click Edit Script Paste in the script and click OK Now, we need to add the tool to your workspace. Click Tools - Workspaces - Edit Current Workspace Click on the Menus tab Find the assigned category and expand it in the box on the left Choose a menu to place it in and expand it in the box on the right Click and drag the tool from the left to the expanded menu on the right Click OK You should be good to go. If I get around to adding a dialog box, I'll probably make it a more full blown plug-in rather than a quick script, and will detail the install process. It's less complicated than what's above but still not all that intuitive. 7 Quote Link to comment
Gilbert Osmond Posted June 9, 2021 Author Share Posted June 9, 2021 9 hours ago, Jesse Cogswell said: Glad to hear that this worked. .... ... It's less complicated than what's above but still not all that intuitive. This is fantastic work. If you accept donations via cryptocurrency or some other online tips platform, consider posting it so I can compensate you for what this is worth to me. At least $50 USD. Thanks again & I look forward to ongoing refinements time-permitting. 3 Quote Link to comment
Jesse Cogswell Posted June 17, 2021 Share Posted June 17, 2021 I apologize for the delay, last week was a bit rougher than expected. I have fleshed this out a bit more, opening a dialog box allowing you to choose the "direction" of the locus points when producing the polyline, whether or not the polyline is closed, whether or not the source locus points are deleted, and which class and layer the polyline will appear in. The script also remembers your last choices for direction, closed poly, and delete points to save a little bit of time when running this tool if you don't need to change settings. Class and layer will always default to the active class and layer when you run the tool. Screenshot of dialog box The tool is attached as a .zip file. Installation is mostly painless, but to start, you will want to make sure that if you saved the previous version of the tool using the Plug-in Manager, you will need to make sure to either delete the previous tool or to change the name to something other than Create Poly from Locus Pts. After doing that, follow the steps below. Download the attached .zip file to a convenient location. DO NOT unzip it. Click Tools - Plug-ins - Plug-in Manager Click on the Third-party Plug-ins tab Click on the Install button Point the Explorer/Finder to the downloaded .zip file Restart Vectorworks Add the tool to your workspace following the steps outlined in my previous post. You will find it under the JNC category. @Gilbert Osmond , your offer is a pleasant surprise and very well appreciated. I am a bit conflicted about this, as I answer questions on here as a way to help others navigate the oftentimes opaque documentation from Vectorworks and the usual list of workarounds you sometimes have to use to make Vectorworks fit into different workflows (as someone on here once called "Vectorworkarounds"). I have a large frustration with broken tools and feature requests go unanswered year upon year when it seems that Vectorworks would rather focus on adding half-baked features that often don't work properly out of the box. This is why I don't mind putting some time toward some of the more "simple" feature requests. I also enjoy the strict problem solving of programming as a break from my usual work (when time allows). All that being said, I also won't turn down money, so if you still want to send me a tip, the best bet would be Paypal, and I can DM you the relevant email address. Please let me know if you see anything weird with this tool. I did some pretty rigorous testing in VW2019 to make sure that stacking order wouldn't interfere with the Left-Right or Top-Down directions, but the algorithm is a bit tricky and there may still be some bugs in it. Create Poly From Locus Pts.zip 1 Quote Link to comment
Dhananjay Naidu Posted October 14, 2022 Share Posted October 14, 2022 On 6/9/2021 at 8:53 AM, Jesse Cogswell said: I could write a script that could pull in the XYZ locations of all selected loci and essentially use that data to "connect the dots" with a 3D polygon, but I think the biggest obstacle to making it work properly is that there is no real way to pull the order in which connect the loci. Calling a ForEachObject callback would be the most efficient, but it will follow in the order in which the loci were created with little regard to their physical location. Imagine you wanted to create a square with four loci, A (0,0), B (1,0), C (1,1), and D (0,1). There's no real easy way to tell the script to create a poly in A,B,C,D order, the script might create a poly in A,C,D,B order, resulting in an hourglass shape. Someone much smarter than me could probably write an algorithm to determine a clockwise or anti-clockwise path between a selection of points, but I can't think of an easy way off the top of my head without attaching a record to each loci with the poly creation order in it, but assigning that would take more time than drawing the polygon by hand. If you can assure that the points are created in the correct order, then the script below should do the trick. PROCEDURE CreatePolyFromPoints; {* Creates a 2D polygon from a selection of 2D Locus points and/or a 3D polygon from a selection of 3D Locus points Developed by: Jesse Cogswell Date: 6/8/2021 VW Version: 2019 *} VAR lociPoints:DYNARRAY[] OF POINT; lociPoints3D:DYNARRAY[] OF POINT3D; numPoints:INTEGER; currentLayer:STRING; finalPoly,finalPoly3D:HANDLE; deleteCheck:BOOLEAN; PROCEDURE PollThePoints(h:HANDLE); {Generates array of XY locations of selected points} VAR p1:POINT; BEGIN numPoints:=numPoints+1; ALLOCATE lociPoints[1..numPoints]; GetLocPt(h,p1.x,p1.y); lociPoints[numPoints]:=p1; IF(deleteCheck=TRUE) THEN DelObject(h); END; PROCEDURE PollThePoints3D(h:HANDLE); {Generates array of XYZ locations of selected 3D points} VAR p1:POINT3D; BEGIN numPoints:=numPoints+1; ALLOCATE lociPoints3D[1..numPoints]; Get3DCntr(h,p1.x,p1.y,p1.z); lociPoints3D[numPoints]:=p1; IF(deleteCheck=TRUE) THEN DelObject(h); END; FUNCTION CreatePolygon(points:DYNARRAY[] OF POINT; nPoints:INTEGER) : HANDLE; {Creates a polygon from given array of points and returns handle to polygon} VAR i:INTEGER; h:HANDLE; BEGIN ClosePoly; BeginPoly; FOR i:=1 TO nPoints DO AddPoint(points[i].x,points[i].y); EndPoly; CreatePolygon:=LNewObj; END; FUNCTION CreatePolygon3D(points:DYNARRAY[] OF POINT3D; nPoints:INTEGER) : HANDLE; {Creates a 3D polygon from given array of points and returns handle to polygon} VAR i:INTEGER; h:HANDLE; BEGIN CLosePoly; BeginPoly3D; FOR i:=1 TO nPoints DO Add3DPt(points[i].x,points[i].y,points[i].z); EndPoly3D; CreatePolygon3D:=LNewObj; END; BEGIN numPoints:=0; currentLayer:=GetLName(ActLayer); deleteCheck:=YNDialog('Delete Locus Points after creation?'); ForEachObject(PollThePoints,((SEL=TRUE) & (L=currentLayer) & (T=LOCUS))); IF(numPoints>1) THEN finalPoly:=CreatePolygon(lociPoints,numPoints); numPoints:=0; ForEachObject(PollThePoints3D,((SEL=TRUE) & (L=currentLayer) & (T=LOCUS3D))); IF(numPoints>1) THEN finalPoly3D:=CreatePolygon3D(lociPoints3D,numPoints); END; Run(CreatePolyFromPoints); The script will follow the points in the order of their creation and gives you an option to delete the locus points afterward. The script will handle 2D and 3D locus points and will generate accordingly, but separately. If you include a selection of 2D and 3D points, the script will generate a separate 2D and 3D polygon. Also keep in mind that it will be restricted to points on the active layer only to prevent it from misreading points still selected on a different layer (in case your Layer Options are set to Show/Snap). Let me know if this works for you or if this totally breaks something. It worked in my admittedly brief amount of testing on VW2019, but there's no reason it shouldn't work in VW2021. Works for me in VW 2023. Many thanks Quote Link to comment
DSmith2300 Posted February 8, 2023 Share Posted February 8, 2023 I've just found this. Looking forward to using it as I struggle through learning site modelling. VW should give you a fee and incorporate your work. Many thanks. I envy your coding brain, as mine can barely count to potato. 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.