[Closed] Spline question
Hi, first off I’d just like to say thanks for reading this. OK, I’ve never really used MaxScript before, and what little I’ve done is only emulating the basic creation of objects that the MaxScript Listener shows.
I’m trying to create a spline line that goes from point A to point B. Pretty simple stuff right? I need the line to be renderable. Pretty much I have a spreadsheet of points in space, and I need lines to connect these points.
Question 1 is how do I input the vertex position data?
line pos:[0,0,0] isSelected:on wirecolor:(color 255 255 255)
That’s what the MaxScript Listener shows when I create a new line, no matter what the points are. But I don’t see where the 2 vertices get input.
Question 2 is how do I make the line renderable?
MaxScript Listener doesn’t show anything when I use the check box for renderable option.
I’m more of a data input type guy myself, and couldn’t figure this out if you gave me month on my own.
Max 5.0
– first you have to create a shape
s = splineshape()
– it seems backwards, but next you have to add
– a spline segment to the shape
idx = addNewSpline s
– now you can start adding knots to the spline.
– this code assumes you already have an array
– of point3 values for your knot positions
for k in knot_positions do addKnot s idx #smooth #curve k
– now, after updating the shape, you should
– see your spline in the viewports!
updateShape s
– here’s how you set the renderable and thickness properties
s.baseobject.renderable = true
s.thickness = 0.5
– and you can display the render mesh in the
– viewports like this
s.displayrendermesh = true
RH
Originally posted by JeBuS27
[B]
Question 2 is how do I make the line renderable?MaxScript Listener doesn’t show anything when I use the check box for renderable option.
…Max 5.0 [/B]
Short addition to Roger’s excellent answer.
First, you have hit one of the few “special cases” in MAXScript that required additional explanations and large NOTE paragraphs in the Help.
The .renderable property of the splines was implemented after the original MAXScript implementation during Max 1.x times. At that point, every geometry object already had a .renderable property in the Object Properties dialog that controlled the visibility to the renderer.
When the Spline’s renderable property was introduced, it was given the same name which led to an internal name conflict. (I assume this could be seen as a bug, but when it was noticed, it was probably too late to change the system without breaking old scripts, so it remained this way up until 6.0)
That’s why you cannot just flip the state of the yourSpline.renderable property (which toggles the checkbox in the Object Properties), you MUST use yourSpline.baseObject.renderable which references the base object seen at the bottom of the modifier stack and will toggle the correct checkbox to turn the spline into a renderable mesh…
And a second point – the Question “How do I create a line between two points” was added to the new FAQ section in the MAXScript Online Help for Max 6.0 along with answers to many other typical questions posted to this and other forums. JFYI, should you upgrade to 6.x someday…
Cheers,
Bobo
Hey, thanks for the responses guys. I ended up finding a work-around for my problem while waiting for the first response. And it is working out quite well for me. I just used planes with the angle figured out by using a little trigonometry.
Can one assign different thicknessess along the rendermesh?
Sorry for butting in but this is something I have being trying to solve for some time. Beleive me I am king novice here.
PM
Unfortunately, you can’t do that. To do something like that, you’d have to write a custom extrusion routine that follows the spline, which would be far from trivial for the novice programmer. However, if you’ve got the fortitude to try it, I’d recommend looking at the extrude along spline code from Meshtools (or was it csPolyTools, my memory fails me!) for some pointers about how to tackle such a thing. Somebody (I think it was Chris Johnson) also wrote some sort of “draw extrusion” script that might prove useful, so long as it’s not an encrypted source. These tools should be available at www.scriptspot.com.
If you go for it, best of luck to you:thumbsup:
RH
Custom extrusion routine??!
😮
Thank you for the pointer.
It looks like too many sleepless nights, but it is good to know the limits.
Although I will checkout the links you offered.
Pm