[Closed] Loft and Maxscript OR Alternatives
Hi all,
I’m working on a little project where I really need to use loft from within maxscript, but after some reading it looks as though the loft feature is not available via maxscript.
I have sieved through many forums but cannot find a solution.
So, are there any alternatives that have the same capabilities, i.e. loft through many shapes along a spline?
Also is it possible to control a loft with maxscript that has already been created in the scene?
Any help would be greatly appreciated.
you can start from some code similar to this:
(
local stShapeName = "Shape"
global GetShapeNotification
fn GetShapeNotification =
(
local hwnd = dialogMonitorOps.getWindowHandle()
local dialogTitle = uiAccessor.getWindowText hwnd
if (dialogTitle == "Pick Object") then (
local dialogChildren = windows.getChildrenHWND hwnd
UIAccessor.SetWindowText dialogChildren[15][1] stShapeName
UIAccessor.PressDefaultButton()
)
true
) --end fn GetShapeNotification =
fn GenerateLoft nodePath =
(
--constants for windows messages
select nodePath
--loft creation
macros.run "Objects Compounds" "Loft"
local mainHWND = windows.getDesktopHWND()
local children = windows.getChildrenHWND mainHWND
local stToSearch = "Get Shape"
local btnGetShape = undefined
for child in children where child[5] == stToSearch do btnGetShape = child
local btnGetShape_hwnd = btnGetShape[1]
UIAccessor.pressButton btnGetShape_hwnd
--Get shape
DialogMonitorOPS.RegisterNotification GetShapeNotification id:#GetShapePopUp
DialogMonitorOPS.enabled = true
max tool hlist
DialogMonitorOPS.unRegisterNotification id:#GetShapePopUp --not needed more
DialogMonitorOPS.enabled = false
UIAccessor.pressButton btnGetShape_hwnd
local nodeLoft = selection[1]
--do what you want with the loft
)
delete objects
local nodePath = splineShape name:"Path"
addNewSpline nodePath
for i = 0 to 50 by 10 do
addKnot nodePath 1 #smooth #curve [random -10 10, i,0]
local nodeShape = splineShape name:"Shape"
addNewSpline nodeShape
addKnot nodeShape 1 #corner #curve [1, 0,0]
addKnot nodeShape 1 #corner #curve [1, 1,0]
addKnot nodeShape 1 #corner #curve [-1, 1,0]
addKnot nodeShape 1 #corner #curve [-1, 0,0]
stShapeName = nodeShape.name
GenerateLoft nodePath
)
This has a lot of limitations and improvements but you can create a lot of lofts in scripted ways and can be mapped.
When you have the loft you can do some stuff with windows handlers to change the loft properties. Search for Zeboxx2 posts to know how.
Thank you very much!!
This is working very well.
I thought that there would be a “dirty” way of doing this but my knowledge of MXS is not substantial enough to know how.
Thank you again.
run away now don’t look back don’t hesitate just run. you are entering a world of pain!
though it’s relatively simple (and quite quick) to generate a lofted mesh with mxs and by doing so circumvent the sorry loft compound object’s lack of scripting. You will never be able to exactly match it’s output as mxs does not have access to some spline attributes e.g. adaptive subdivisions. Also autodesk in their infinite wisdom doesn’t pulish the source code for this so the exact method for the loft Frenet generation is not known.