<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Extending the Sweep built in shapes in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/extending-the-sweep-built-in-shapes/m-p/13952081#M29312</link>
    <description>&lt;P&gt;I'm trying to create a library of Sweep shapes by expanding the built in list, but I'm having problems getting it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, I created a new shape type using the &lt;STRONG&gt;plugin simpleSpline&lt;/STRONG&gt;&amp;nbsp;system. The script file is in my startup folder, and my new shape appears in the&amp;nbsp;modifier panel under&amp;nbsp;&lt;STRONG&gt;Create -&amp;gt; Shape -&amp;gt; RayScripts&lt;/STRONG&gt;&amp;nbsp;as expected. I can choose on my new shape and draw it in the viewport. I have a parameters panel exposed, and adjusting the values causes the shape to redraw properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly, I modified the&amp;nbsp;&lt;STRONG&gt;\plugcfg\sweep.ini&lt;/STRONG&gt; file to add my custom shape. I added it to the end of the&amp;nbsp;&lt;STRONG&gt;BuiltInSections&lt;/STRONG&gt; list in the &lt;STRONG&gt;Global&lt;/STRONG&gt; section, and then I defined my shape by cloning the Cylinder entry, renaming it and setting the ClassID to match my &lt;STRONG&gt;plugin simpleSpline&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I restart Max 2025 and create a new sweep modifier, I see my new shape at the bottom of the list of built in shapes, but selecting it does nothing. It does not use my shape and I don't see any parameter rollouts for my shape.&amp;nbsp; I feel like I'm almost there, but I can't seem to figure out what to do next.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my custom shape code:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;plugin simpleSpline splineSegment
	name:"Spline Segment"
	classID:#(0x52617943, 0x53504C31) 
	category:"RayScripts"
	usePBValidity:true
(
	local bezierShapeClass = dotNetClass "Autodesk.Max.MaxPlus.BezierShape"
	local splineKnot = dotNetClass "Autodesk.Max.MaxPlus.SplineKnot"
	local vector3 = dotNetClass "Autodesk.Max.MaxPlus.Point3"
	local bezierKnot = (dotNetClass "Autodesk.Max.MaxPlus.SplineKnot+KnotType").BezierKnot 
	local curveLine = (dotNetClass "Autodesk.Max.MaxPlus.SplineKnot+LineType").CurveLineType
	local initialized = true
	fn vec3 xyz = dotNetObject vector3 xyz.x xyz.y xyz.z
	fn getSplineKnot pos inVec outVec = dotNetObject splineKnot bezierKnot curveLine (vec3 pos) (vec3 (pos + inVec)) (vec3 (pos + outVec))
	fn getPointPlaneProjection pos pTM = pos + dot (pTM.translation - pos) pTM.row3 * pTM.row3

	parameters main rollout:params (
		segLen default:5 type:#worldUnits animatable:on ui:segLen_spn
		
		on segLen set val do if initialized do this.rebuildShape()
		changed default:true type:#boolean invisibleInTV:true
	)
	fn orient &amp;amp;nodeTM pos = (
		local projPos = getPointPlaneProjection pos nodeTM
		local x = normalize (projPos - nodeTM.translation)
		if keyboard.shiftPressed do case of
		(
			(abs (dot x x_axis) &amp;gt; abs (dot x y_axis)): x = if dot x x_axis &amp;gt; 0 then x_axis else -x_axis
			(abs (dot x y_axis) &amp;gt; abs (dot x x_axis)): x = if dot x y_axis &amp;gt; 0 then y_axis else -y_axis
		)
		local y = cross nodeTM.row3 x 
		nodeTM = matrix3 x y (cross x y) nodeTM.translation
		projPos
	)
	fn makeSeg addNext = (
		addNext (getSplineKnot [segLen / -2.0, 0, 0] \
		                       [0, 0, 0] \
		                       [0, 0, 0])
		addNext (getSplineKnot [segLen / 2.0, 0, 0] \
		                       [0, 0, 0] \
		                       [0, 0, 0])
	)
	fn rebuildShape = (
		local shapeWrapper = bezierShapeClass._CreateWrapperFromFPValue BezierShape
		shapeWrapper.NewShape()
		local spline = shapeWrapper.NewSpline()
		makeSeg spline.AddKnot
		shapeWrapper.UpdateSels()
		shapeWrapper.InvalidateGeomCache()
		changed = false
	)
	rollout params "Parameters" (
		spinner segLen_spn "Segment Length: " range:[1e-9, 1e9, 5] type:#worldUnits align:#right offset:[10,0]
	)
	tool create numPoints:2 (
		local center

		on mousePoint click do case click of
		(
			1: nodeTM.translation = gridPoint
		)
		on mouseMove click do case click of
		(
			2: segLen = (distance nodeTM.translation (orient &amp;amp;nodeTM gridPoint)) * 2.0
		)
	)
	on create do initialized = false
	on postCreate do initialized = true
	on clone orig do segLen = segLen
	on buildShape do if changed do rebuildShape()
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My modification/addition to the sweep.ini&lt;/P&gt;&lt;LI-CODE lang="general"&gt;[Global]
BuiltInSections= Angle,Bar,Channel,Cylinder,Half Round,Pipe,Quarter Round,Tee,Tube,Wide Flange,Egg,Ellipse,splineSegment



[splineSegment]
ClassID= 52617943, 53504C31
IconFile=Sweep_DefaultSections
IconIndex=9
NumDefaults= 1
Default1= 0,float,10.000000&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Dec 2025 22:44:12 GMT</pubDate>
    <dc:creator>Ray.Collett</dc:creator>
    <dc:date>2025-12-19T22:44:12Z</dc:date>
    <item>
      <title>Extending the Sweep built in shapes</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/extending-the-sweep-built-in-shapes/m-p/13952081#M29312</link>
      <description>&lt;P&gt;I'm trying to create a library of Sweep shapes by expanding the built in list, but I'm having problems getting it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, I created a new shape type using the &lt;STRONG&gt;plugin simpleSpline&lt;/STRONG&gt;&amp;nbsp;system. The script file is in my startup folder, and my new shape appears in the&amp;nbsp;modifier panel under&amp;nbsp;&lt;STRONG&gt;Create -&amp;gt; Shape -&amp;gt; RayScripts&lt;/STRONG&gt;&amp;nbsp;as expected. I can choose on my new shape and draw it in the viewport. I have a parameters panel exposed, and adjusting the values causes the shape to redraw properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly, I modified the&amp;nbsp;&lt;STRONG&gt;\plugcfg\sweep.ini&lt;/STRONG&gt; file to add my custom shape. I added it to the end of the&amp;nbsp;&lt;STRONG&gt;BuiltInSections&lt;/STRONG&gt; list in the &lt;STRONG&gt;Global&lt;/STRONG&gt; section, and then I defined my shape by cloning the Cylinder entry, renaming it and setting the ClassID to match my &lt;STRONG&gt;plugin simpleSpline&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I restart Max 2025 and create a new sweep modifier, I see my new shape at the bottom of the list of built in shapes, but selecting it does nothing. It does not use my shape and I don't see any parameter rollouts for my shape.&amp;nbsp; I feel like I'm almost there, but I can't seem to figure out what to do next.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my custom shape code:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;plugin simpleSpline splineSegment
	name:"Spline Segment"
	classID:#(0x52617943, 0x53504C31) 
	category:"RayScripts"
	usePBValidity:true
(
	local bezierShapeClass = dotNetClass "Autodesk.Max.MaxPlus.BezierShape"
	local splineKnot = dotNetClass "Autodesk.Max.MaxPlus.SplineKnot"
	local vector3 = dotNetClass "Autodesk.Max.MaxPlus.Point3"
	local bezierKnot = (dotNetClass "Autodesk.Max.MaxPlus.SplineKnot+KnotType").BezierKnot 
	local curveLine = (dotNetClass "Autodesk.Max.MaxPlus.SplineKnot+LineType").CurveLineType
	local initialized = true
	fn vec3 xyz = dotNetObject vector3 xyz.x xyz.y xyz.z
	fn getSplineKnot pos inVec outVec = dotNetObject splineKnot bezierKnot curveLine (vec3 pos) (vec3 (pos + inVec)) (vec3 (pos + outVec))
	fn getPointPlaneProjection pos pTM = pos + dot (pTM.translation - pos) pTM.row3 * pTM.row3

	parameters main rollout:params (
		segLen default:5 type:#worldUnits animatable:on ui:segLen_spn
		
		on segLen set val do if initialized do this.rebuildShape()
		changed default:true type:#boolean invisibleInTV:true
	)
	fn orient &amp;amp;nodeTM pos = (
		local projPos = getPointPlaneProjection pos nodeTM
		local x = normalize (projPos - nodeTM.translation)
		if keyboard.shiftPressed do case of
		(
			(abs (dot x x_axis) &amp;gt; abs (dot x y_axis)): x = if dot x x_axis &amp;gt; 0 then x_axis else -x_axis
			(abs (dot x y_axis) &amp;gt; abs (dot x x_axis)): x = if dot x y_axis &amp;gt; 0 then y_axis else -y_axis
		)
		local y = cross nodeTM.row3 x 
		nodeTM = matrix3 x y (cross x y) nodeTM.translation
		projPos
	)
	fn makeSeg addNext = (
		addNext (getSplineKnot [segLen / -2.0, 0, 0] \
		                       [0, 0, 0] \
		                       [0, 0, 0])
		addNext (getSplineKnot [segLen / 2.0, 0, 0] \
		                       [0, 0, 0] \
		                       [0, 0, 0])
	)
	fn rebuildShape = (
		local shapeWrapper = bezierShapeClass._CreateWrapperFromFPValue BezierShape
		shapeWrapper.NewShape()
		local spline = shapeWrapper.NewSpline()
		makeSeg spline.AddKnot
		shapeWrapper.UpdateSels()
		shapeWrapper.InvalidateGeomCache()
		changed = false
	)
	rollout params "Parameters" (
		spinner segLen_spn "Segment Length: " range:[1e-9, 1e9, 5] type:#worldUnits align:#right offset:[10,0]
	)
	tool create numPoints:2 (
		local center

		on mousePoint click do case click of
		(
			1: nodeTM.translation = gridPoint
		)
		on mouseMove click do case click of
		(
			2: segLen = (distance nodeTM.translation (orient &amp;amp;nodeTM gridPoint)) * 2.0
		)
	)
	on create do initialized = false
	on postCreate do initialized = true
	on clone orig do segLen = segLen
	on buildShape do if changed do rebuildShape()
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My modification/addition to the sweep.ini&lt;/P&gt;&lt;LI-CODE lang="general"&gt;[Global]
BuiltInSections= Angle,Bar,Channel,Cylinder,Half Round,Pipe,Quarter Round,Tee,Tube,Wide Flange,Egg,Ellipse,splineSegment



[splineSegment]
ClassID= 52617943, 53504C31
IconFile=Sweep_DefaultSections
IconIndex=9
NumDefaults= 1
Default1= 0,float,10.000000&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Dec 2025 22:44:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/extending-the-sweep-built-in-shapes/m-p/13952081#M29312</guid>
      <dc:creator>Ray.Collett</dc:creator>
      <dc:date>2025-12-19T22:44:12Z</dc:date>
    </item>
  </channel>
</rss>

