Jump to content
Developer Wiki and Function Reference Links ×

hgarnade


Recommended Posts

Has anyone had any luck with scripts for creating dog bones on the internal corners of a path? I create a lot of work for CNC machining and am currently going around by hand creating them. Rhino has a plug-in that runs it automatically. Please tell me there is the same for Vectorworks?! I've been searching online for a long time to no avail. If it makes a difference I'm running v2020.

 

Thank you 🙂

Link to comment
11 hours ago, Pat Stanford said:

I don't understand your terminology. I have never seen anything here about scripting dog bones. If you explain what you really need to do maybe we can help.

 

I think they're referring to this concept, where corners are prepped for CNC work based on the cutter diameter - https://blog.inventables.com/2014/06/learn-about-milling-inside-corner.html

 

Kevin

 

Edited by Kevin McAllister
Link to comment
  • 3 weeks later...

Yes Kevin, that is exactly what I'm talking about. When preparing files for CNC machining you lose the internal corner due to the tool being circular, so to counteract that you can notch out a small circle further into the part. Other softwares have plugins you can use (i.e rhino) to run this procedure and I was hoping someone might have created a similar help in VW 

  • Like 1
Link to comment

For a while it looked like features for digital manufacturing were on the roadmap but I'm not sure they are any more. Too bad really since we're all using CNC, lasercutting, 3d printing etc. in our design and build processes now. JimW was very interested in these technologies. @JuanP is there someone else representing these technologies on the forums now?

 

Kevin

Link to comment

Hello,

 

based on your posts i wrote a little marionette node as a first prototype for a script that maybe can handle this. Please note that i dont have any experience in cnc milling, so i rely on your feedback.

 

Here is the code, simply cope paste the whole code into an existing marionette node and it should work.

This is meant to be just the very first prototype of a script. I just want to know if this is the right direction before i put more effort in it.

 

# by Letti R, 2022 07 19
@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
	#Name
	this = Marionette.Node( "2D mill_dog bone" )
	this.SetDescription( '2D mill_dog bone' )

	#Input Ports
	poly = Marionette.PortIn( vs.Handle(0), 'hPoly' )
	poly.SetDescription( "The input poly" )

	#OIP Controls
	bit_diameter = Marionette.OIPControl( 'bitDiameter', Marionette.WidgetType.RealCoord, 0.0)
	bit_diameter.SetDescription('bitDiameter')
	
	side = Marionette.OIPControl( 'side', Marionette.WidgetType.Popup, 0, ['right', 'left'])
	side.SetDescription('side')

	#Output Ports

#BEHAVIOR
	this.SetLinksObjects()


def RunNode(self):
	#inputs
	poly = self.Params.poly.value
	bit_diameter = self.Params.bit_diameter.value / vs.GetPrefReal(150)
	side = self.Params.side.value
	epsilon = 0.000000001
	
	#functions
	def cross_2D(vector_1, vector_2):
		if len(vector_1) == len(vector_2) and len(vector_1) == 2:
			return(vector_1[0]*vector_2[1] - vector_2[0]*vector_1[1])
		else:
			return(None)
	
	def two_tuples_to_vector(tuple_1, tuple_2):
		lt1 = len(tuple_1)
		lt2 = len(tuple_2)

		if lt1 == lt2:
			list_subtractions = []
			for i in range(lt1):
				list_subtractions.append(tuple_2[i] - tuple_1[i])
			return(tuple(list_subtractions))
		else:
			return(None)
	
	def rotate_list(list, n):
		return(list[n:] + list[:n])
		
	def normalize_tuple(tup):
		tup_squared = []
		for item in tup:
			tup_squared.append(item**2)
		len_tup = math.sqrt(sum(tup_squared))
		
		norm_list = []
		for item in tup:
			norm_list.append(item / len_tup)
		return(tuple(norm_list))
	
	def vector_angle_bisector(vector_1, vector_2):
		normalized_vector_1 = normalize_tuple(vector_1)
		normalized_vector_2 = normalize_tuple(vector_2)
		return(normalize_tuple((normalized_vector_1[0] + normalized_vector_2[0], normalized_vector_1[1] + normalized_vector_2[1])))


	#script
	poly_vertecies = []
	for i in range(vs.GetVertNum(poly)):
		poly_vertecies.append(vs.GetPolylineVertex(poly, i+1)[0])

	vectors_to_this_points = []
	for i in range(len(poly_vertecies)):
		vector_temp_1 = two_tuples_to_vector(poly_vertecies[i-2], poly_vertecies[i-1])
		vector_temp_2 = two_tuples_to_vector(poly_vertecies[i], poly_vertecies[i-1])
		vectors_to_this_points.append((vector_temp_1, vector_temp_2))
	vectors_to_this_points = rotate_list(vectors_to_this_points, 1)
	
	cross_product_of_vectors_to_points = []
	for vectors in vectors_to_this_points:
		cross_product_of_vectors_to_points.append(cross_2D(vectors[0], vectors[1]))

	for i in range(len(poly_vertecies)):
		if bit_diameter and abs(cross_product_of_vectors_to_points[i]) >= epsilon:
		
			run_script =  False
			if side == 0 and cross_product_of_vectors_to_points[i] < 0:
				run_script = True
			
			elif side == 1 and cross_product_of_vectors_to_points[i] > 0:
				run_script = True
			
			if run_script:
				temp_vector_angle_bisector = vector_angle_bisector(vectors_to_this_points[i][0], vectors_to_this_points[i][1])
			
				vs.MoveTo(poly_vertecies[i])
				vs.LineTo((poly_vertecies[i][0] + ((bit_diameter / 2) * temp_vector_angle_bisector[0]), poly_vertecies[i][1] + ((bit_diameter / 2) * temp_vector_angle_bisector[1])))
	

	#outputs

 

 

Regards

Letti

Link to comment

Hello,

 

i turned my previously posted marionette node (which to my shame i have to admit has many errors) into a tool. I tried to replicate the functions of a script for rhino which i found online.

 

The tool can now add "bones" to corners like this:

mill_01.thumb.PNG.6f657ce72e839ba40797a233a299f857.PNG 

 

The tool can create "bones" on every corner regardless of the angle. It works on closed polygons and closed polylines, but not yet on polylines with holes. Creating your own holes should still be easy because the tool can also add "bones" to convex corners.

The tool works by clicking on the corners where you want to draw a "bone". It is also possible to draw the same kind of "bone" on every corner of the polygon that is of the same type (concave or convex) as the corner you clicked on.

 

Please message me if you want to try this tool. I dont want to post it publicly yet.

 

 

Regards

Letti

 

 

  • Like 3
Link to comment
  • 4 months later...

Hello,

 

after some changes and bug fixing, i am happy to share the tool with you that i wrote for @hgarnade.

 

The tool automates the creation of “Dog-Bone” and “T-Bone” fillets in VW. Dog-Bones and T-Bones are used to deal with the rounded inner corners, that result from the diameter of the mill, when cutting materials with a CNC.

This solution is often used to create joints, where one piece must fit precisely in a hole.

1470762277_MillFill_3.PNG.27016c5f52b71937dc66f67cc3e3117a.PNG

Here is a short video on how the tool is used.

 

The tool works on Rectangles, Polygons and Polylines. Currently the tool does not work if you are inside a group, symbol, extrude etc.

If you have any problems with the tool, or an idea on how to improve it, please feel free to message me.

Thanks to @hgarnade for the feedback while testing early versions of the tool.

 

Use at own risk. Although the tool has been thoroughly tested, bugs cannot be ruled out. Please consider saving your VW file before using this tool.

 

 

Regards,

Letti

2D Mill Fill 2023.vst

Link to comment
  • 2 months later...

Hello,

 

here is a new version of the tool.

I fixed an error that occured when the document units were set to imperial with unit marks displayed. This error did not cause wrong results in your drawings (for example wrong bit diameter or wrong additional bone length), the tool just was not able to run under the mentioned circumstances.

 

If you are using imperial units please dont use the document settings "feet and inches" together with this tool, as this will likely result in very small rounding errors in the bit diameter and additional bone length. However if you use the settings only "inches" or only "feet" this rounding error will not occur.

 

Thanks to @Ken S. for reporting this error and helping me to fix it.

 

Also if someone knows the proper way to deal with user input in imperial units in vw, i would realy like to learn about it.

 

Regards,

Letti

2D Mill Fill_0_2_1.vst

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...