Frederic_Vbc Posted September 28, 2022 Share Posted September 28, 2022 (edited) Hi, I would like to create a network that create new polygons based on an existing one and a condition. The idea is to 'highlight' (create a new poly) the portion of the polygon where the area width is less than a given distance (here 1500mm). I can think of two avenues to approach this : One might be to run a polyline offset around the boundary and use the intersecting point as delimitation for the new poly. (which is kind of what I do manually) But then I am stuck with translating the use of the 'bucket' 2D polygon Tool : Inner boundary Mode in marionette ? Another approach I was thinking was to use the proximity test (using part of Sbarrett's wrapper) of a series of 2D points on the poly and filter them with a condition, (and ignore a certain amount of consecutive ones I guess to avoid false positive) Would someone have a better idea or have done something similar ? Thanks Fred Edited September 28, 2022 by Frederic_Vbc Quote Link to comment
Pat Stanford Posted September 28, 2022 Share Posted September 28, 2022 I have no idea about how to accomplish this via Marionette. If you were using Vectorscript or Python, there is a function called ClosestPoints. You pass it two handles and it determines the two points (one on each object) that are closest together. It seems that if you broke the polyline down into segments (keeping the curves) then you could compare each of the segments against every other segment and at least get a smaller subset of objects you need to compare more carefully. For straight parallel edges it would be pretty easy. For the curved sections where you only want part of the segment it will be trickier. Quote Link to comment
Frederic_Vbc Posted September 28, 2022 Author Share Posted September 28, 2022 Thanks Pat, Unfortunately I am not yet familiar with Vectorscript or Python. I have been trying to create a node to decompose a polyline into segment based on the node "Compose" but I am getting an error : NameError ("name 'hPoly' is not defined" I am a bit out of my depth here... @Marionette.NodeDefinition class Params(metaclass = Marionette.OrderedClass): #APPEARANCE #Name this = Marionette.Node( 'Decompose' ) this.SetDescription('Decompose similar to how the Decompose menu command would.') #Input Ports hPoly = Marionette.PortInLists( [],'Poly') hPoly.SetDescription('A poly') #OIP Controls #Output Ports out = Marionette.PortOut('Vertices') out.SetDescription('The resulting vertices') #BEHAVIOR this.SetLinksObjects() def RunNode(self): #functions def Add_Handle(obj): out_list.append(obj) #inputs Poly = self.Params.hPoly.value #script out_list = [] vs.DSelectAll() for h in hPoly: vs.SetSelect(( vs.CreateDuplicateObject(h, vs.Handle(0)) )) vs.Marionette_DisposeObj(h) vs.DoMenuTextByName('Decompose', 0) vs.ForEachObject(Add_Handle,'(VSEL=TRUE)') #outputs self.Params.out.value = out_list 1 Quote Link to comment
m.graf Posted September 28, 2022 Share Posted September 28, 2022 (edited) "for h in hPoly: try: for h in Poly: greatings M.Graf Edited September 28, 2022 by m.graf Quote Link to comment
Frederic_Vbc Posted September 28, 2022 Author Share Posted September 28, 2022 12 hours ago, m.graf said: "for h in hPoly: try: for h in Poly: greatings M.Graf Ahhh you got it right m.graf, thank you ! Quote Link to comment
Letti R Posted October 2, 2022 Share Posted October 2, 2022 Hello, i tried to write a Marionette Node to do that, but i think i did not succeed. However i want to share what i did, maybe it helps a bit. Please note that i wrote this Node in a hurry and did not care about good code at all! I wrote the code of the Node into a .txt file, because i only have an edu version of vwx, so i cant share the .vwx file. If you want to try this Node just copy the whole code from the .txt into an empty Node. This Node only works on closed polygons and checks the width of the polygon for each edge of the the polygon individualy and draws another polygon to highlight the area where the "width of the polygon" is smaller than some value. I think that this is NOT a solution, because i dont think this "definition" of the "width of the polygon" is very useful. For example in corners with an acute angle it does this (see picture), because it checks every edge in a 90 degrees angle individualy: Regards, Letti 221002_node_tst poly width.txt 1 Quote Link to comment
Frederic_Vbc Posted October 4, 2022 Author Share Posted October 4, 2022 Wow that's great and impressive Letti ! The result looks to be very close to what I was looking for. Your code is far beyond my scripting level but I will study it and try to learn from it. Thank you for your time ! Quote Link to comment
Letti R Posted October 4, 2022 Share Posted October 4, 2022 Hello, if you want to understand the code here is what it basically does: Draw a rectangle with the width that you want to test for on the edge of the polygon you want to test so that it overlaps with the polygon Subtract the polygon from the rectangle. If the subtraction creates a new object (or new objects), get all vertecties of this object that are on the polygon you want to test Project the vertecies onto the edge you started with Draw polygons between the vertecies on the polygon (from step 2.) and the vertecies that were projected onto the edge (from step 3.) you started with Create the intersection between the polygon you want to test and the polygons that were created in step 4. Add up the polygons from step 5. Repeat Step 1. to 6. for every edge of the polygon you want to test I think this works just fine for polygons with 90° angles, but not at all for polygons that were converted from polylines with curves. Also the boolean operations in the code makes it realy slow for polygons with many edges. So be careful, vectorworks may crash if the polygon you are testing has to many edges. This is an example what the node does with curves. I dont think this is very useful: I am realy interested to see if someone comes up with an approach that has better results for polylines. Regards, Letti 1 Quote Link to comment
Frederic_Vbc Posted October 7, 2022 Author Share Posted October 7, 2022 Thanks a lot Letti, I will let you know if I make any progress ! 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.