Jump to content

3D Fillet??

Recommended Posts

  • 2 years later...

There are some old threads for this theme but it seems, there is no proper solution.
I also searching for an elegant solution to make fillet on NURBS Curves. As the Tool works fantastic,  by script it seems to be not so trivial. Maybe because we need to combine somehow several segment of NURBS and not all parameters can be edited by script.

So far I tinkered an approximated solution, which seems to work for my usecase it is exact enough and works but somehow not pleased yet for nitpicker like me and many of us 🙂 Target is to model filled NURBS for modeling pipes without using compose as menu command.

The Script:
The calculation of the control points is exact. Also think about to stop pipe, insert a corner segment with right rotation (because calculation of the plane and points already done in this script) Also this could improve dramatically level of detail instead of a path extrude, which anyway have some issues when profile is bigger than radius.
It normalize the segment line and generates offset points from the vertex points. One control point with offset from the corner point with diameter and another control point diameter * (2**0.5 -1). The same as we got with the filled tool. The issue seems to be creating a "double" point with ends line segment to a radius NURBS. We get that with the tool but by script it is still a secret. I "solved" by giving a big weight (10) at the end of the line segment and weight 1 at the control points. It draws nearly an exact radius.

I hope maybe join again the thema and help improving the solution or can use the existing approximative method.

import math 

sqr2 = 0.41421356237 #faster to have constante value instead of calculation 2**0.5 several times I guess
def point_on_line_3D(p1, p2, d): #3d Points d = distance from p1 to p2
	x1, y1, z1 = p1
	x2, y2, z2 = p2
	# a little long but it just substract p1 from p2, then normalize and then multiply with new lengt and add to old point
	c = vs.Distance3D(x1, y1, z1, x2, y2, z2)
	new_pt = ((x2 - x1) / c * d + x1,  (y2- y1) / c * d + y1 , (z2 - z1) / c * d + z1)
	return new_pt

nurbsObj = vs.FSActLayer() # take care to select a NURBS curve

radius = 100
segments = []

points = []
segmentCnt = vs.NurbsCurveGetNumPieces(nurbsObj)
for segm in range(0, segmentCnt): # python range is always one less than pascal
	pts = []
	vtxCnt = vs.NurbsGetNumPts(nurbsObj, segm)
	num_knot = vs.NurbsNumKnots(nurbsObj, segm)
	for vtx in range(0, vtxCnt): # python range is always one less than pascal
		v = vs.NurbsGetPt3D(nurbsObj, segm, vtx)
		if vtx < vtxCnt - 1: #some code of the developper wiki
			p1 = v
			p2 = vs.NurbsGetPt3D(nurbsObj, segm, vtx+1)
			#vs.Locus3D(p1); points.append(p1) #corner point
			p = point_on_line_3D(p1, p2, radius*sqr2)
			points.append([p,1]); #points.append(p)		
			p = point_on_line_3D(p1, p2, radius) #start radius point
			p = point_on_line_3D(p2, p1, radius) #start radius point
			p = point_on_line_3D(p2, p1, radius*sqr2)
			points.append([p,1]); #points.append(p)					

	segments.append([vtxCnt, num_knot, pts])	
new_curve = vs.CreateNurbsCurve(points[0][0][0],points[0][0][1],points[0][0][2],True,3);

for i in range(1, len(points)):
	p, weight = points[i]
	vs.AddVertex3D(new_curve,  p)
	vs.NurbsSetWeight(new_curve, 0, i, weight)

num_knots = vs.NurbsNumKnots(new_curve, 0)

for i in range(num_knots-3):


Fillet v2022.vwx

Link to comment

The function reference suggests that a group of nurbs can be converted to a nurbs object.

Would it not simply be a matter of creating a 2d arc on a plane, rotating it, convert to nurbs, group the resulting nurb with the abutting nurbs and convert to nurbs again to produce the continuous nurbs object?? If it works in that manner you would not need to invoke the compose menu command. I didn't try it out myself. I just based the idea upon this statement from the Script Function Reference for the ConvertToNURBS function. It may not accept a handle to a group of nurbs as input. I think the only way for the result to be a group of nurbs would be for the input handle to somehow represent more than one object.


This function converts the input object into a new NURBS object or a group of NURBS objects in the document."

Link to comment

Thanks for input Larry and Pat.
ConvertToNURBS can't put several segments together. If that is possible it would also not be needed to draw planar polylines and rotate them into the 3D Plane. I have corner points and control points already calculated and can directly draw a NURBS in 3D. It seems, that the hurdle is, that one segment of NURBS can only handle one type of vertex. Rounded vertex or edge vertex. every time we have an unrounded edge we have to create a new segment which we can't combine together. Minimum not in an easy way. What I also thought about is, that maybe the NURBS Curve with several NURBS internally is a different object as a single segment. 

What i maybe will try later:
1. Creating the object with different segments seems to be an attractive and proper solution. Also additionally the Level of detail for a fitting can be implemented here.
2. Menu Command compose making to work inside a Marionette PIO. But for that think I have to parent the Object on a layer then compose it and parent it back into the PIO. Which could work but is somehow ass-backward (Translation from "von hinten durch die Brust ins Auge" ?).

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.

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