Spline normalize 2 _Extend Modifier ( how can I snapshot as spline in maxscript ?)

Spline normalize 2 _Extend Modifier ( how can I snapshot as spline in maxscript ?)

majid.adab
Participant Participant
1,399 Views
6 Replies
Message 1 of 7

Spline normalize 2 _Extend Modifier ( how can I snapshot as spline in maxscript ?)

majid.adab
Participant
Participant

Hello everyone

 

When I scroll the spinner, I want to fix my modifier to work without interruption.

 

I wrote this modifier as an extend modifier of normalize_spline2 and for now, I want only to print the number of segments and vertex of the newly normalized spline ( not the baseobject spline ). 

I used many techniques but none of them worked for me. The problem is in the 'copy', 'instance', 'delete', or 'maxops.clonenodes' commands  that I used to copy the spline and then extract data from it. this causes an interruption in the spinner of the modifier.

 

in the second version, I  used snapshot as a mesh but it will convert spline to mesh so I can not access spline data. 

I would be grateful if anyone help me to fix this. I searched ChatGPT and everywhere for about one week.

 

Thanks

0 Likes
Accepted solutions (1)
1,400 Views
6 Replies
Replies (6)
Message 2 of 7

denisT.MaxDoctor
Advisor
Advisor
Accepted solution
fn getSplineObjectNumSegments spline_obj spline_index = 
(
	g = (dotnetclass "autodesk.max.globalinterface").instance
	inode = g.COREInterface14.GetINodeByHandle spline_obj.inode.handle
	obj = (inode.EvalWorldState g.COREInterface.Time true).Obj

	i = spline_index - 1
	if i < obj.Shape_.SplineCount_ do
	(
		(obj.Shape_.GetSpline i).Segments
	)
)

 

You can find more info in the help (sdk help) or/and using #showproperties and #showmethods MXS methods

 

Message 3 of 7

majid.adab
Participant
Participant

🙏🙏👌👌

thank you so much Denis.

it helped me so much.

but I am not very familiar with 'dotnetobject' and 'dotnetclasses' I try to learn it more in the help.

your fn works perfect for splineshapes like circle, Ngon, ....  ( because you used splineshape class ) 
but for lines and shapeobjects it gives and error in line "obj.Shape_.SplineCount_" because .shape is not property of shapeobject class and it is not in showproperties.
Now, I am working on it to fix it for lines and splines too.

thank you so much again.

 

0 Likes
Message 4 of 7

denisT.MaxDoctor
Advisor
Advisor

For which class does it not work? Could you provide an exact example?  

0 Likes
Message 5 of 7

majid.adab
Participant
Participant

@denisT.MaxDoctor wrote:

For which class does it not work? Could you provide an exact example?  


   fn getSplineObjectNumSegments spline_obj = 
(
g = (dotnetclass "autodesk.max.globalinterface").instance
inode = g.COREInterface14.GetINodeByHandle spline_obj.inode.handle
obj = (inode.EvalWorldState g.COREInterface.Time true).Obj
sps = 0
for i=1 to numSplines spline_obj do
(
sp = obj.Shape_.getspline (i-1)
sps = sps + sp.Segments
)
print (sps)
)
getSplineObjectNumSegments $
Hi Denis,
 
exactly the line "sp = obj.Shape_.getspline (i-1) " gives the below error for lines and spline objects.
 
-- Error occurred in anonymous codeblock; filename: ; position: 328; line: 9
-- Unknown property: "Shape_" in dotNetObject:Autodesk.Max.Wrappers.ShapeObject

but as in the screenshot for circles and Ngons and simple spline does not give error.
0 Likes
Message 6 of 7

denisT.MaxDoctor
Advisor
Advisor

Line or Editable_Spline are already ShapeObjects... You can get all the info using built-in MXS methods.

but if we want to practice with MAX .NET:

 

fn getShapeObjectNumSegments spline_obj spline_index = 
(
	g = (dotnetclass "autodesk.max.globalinterface").instance
	inode = g.COREInterface14.GetINodeByHandle spline_obj.inode.handle
	obj = (inode.EvalWorldState g.COREInterface.Time true).Obj

	bz_shape = g.BezierShape.Create()
	obj.MakeBezier g.COREInterface.Time bz_shape
	
	i = spline_index - 1
	if i < bz_shape.SplineCount do
	(
		(bz_shape.GetSpline i).Segments
	)
)

getShapeObjectNumSegments $ 1

 

Message 7 of 7

majid.adab
Participant
Participant

Thank you, Denis.

you are a very expert professional and Helpful man.

 

I read it in the help of dotnetclass and I guess that I should use .MakeBezier to create it.

but I did not know the syntax and how to write it.

 

you taught me a very useful and powerful.

many many thanks.

😍🙏👌

 

 

0 Likes