Jump to content
Developer Wiki and Function Reference Links ×

Marionette - Drawing Analysis : Highlight area based on width


Frederic_Vbc

Recommended Posts

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

 

Marionette project Area.jpg

Edited by Frederic_Vbc
Link to comment

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.

 

 

Link to comment

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

 

  • Like 1
Link to comment

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:

grafik.png.29b0a61b94d488ac824116330a2b4855.png

 

 

Regards,

Letti

221002_node_tst poly width.txt

  • Like 1
Link to comment

Hello,

 

if you want to understand the code here is what it basically does:

  1. 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
  2. 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
  3. Project the vertecies onto the edge you started with
  4. 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
  5. Create the intersection between the polygon you want to test and the polygons that were created in step 4.
  6. Add up the polygons from step 5.
  7. Repeat Step 1. to 6. for every edge of the polygon you want to test

grafik.png.c43bad182619ff5496e5fa897c68544d.png

 

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:

grafik.png.6a96340165aeb60acb6165cf40c9b33e.png

 

I am realy interested to see if someone comes up with an approach that has better results for polylines.

 

Regards,

Letti

  • Like 1
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...