and this is another script… than the one with the lightwave lines right…caus i dont get it anymore:P
oke…for the people who got it to work… explain it step by step plz… caus maybe i am doing somthing wrong…
@ neox & ivo d
i guess you forgot something:
in the editable poly baseobj you have to switch the “use nurms subdivision” on, and set the iterations higher than 0.
also make sure that your viewport is set to edged faces.
proteus,
I was able to fix the memory problem. Apparently while the timer is running Max isn’t cleaning something up with memory internally unless the garbage collector is manually invoked (I just changed how/when it was evoked from the previous script)… It’s fixed now, but at the consequence of flushing out the undo history.
So if you want to use ‘auto update’, go ahead, it’s fixed but an undo history won’t be kept.
If you want to have undo history maintaned, or on/off throughout editing, then switch to manual mode when needed. Just remember that using auto updating erases the undo history each time it is used.
ivo D,
It should work. This isn’t a script for actually doing smooth poly line editing like in Lightwave, this is mainly for visual purposes, like an aid to viewing the mesh and the ‘true’ polylines that directly involved with the editing process.
Here’s the new script:
–Script beginning
–This way works without the internal memory growing forever problem, but at the cost of
–flushing out the undo buffer. i.e.: You can’t undo anything once it’s done
–unless you use the manual update button instead of the auto update
–option
rollout quickOutliner “Polyline Viewer”
(
local x,y,z
local OM
local originalss
checkbutton actDeactChButton “Create Polylines”
button updateButton “Update Polylines” enabled:false
checkBox cageshow “Show Poly Cage” enabled:false
checkBox autoupdateChecker “Auto Update” enabled:false
button closeButton “Close”
timer topochecker interval:1 active:false
timer topoedit interval:1 active:false
on quickOutliner open do (
try (If $.showcage=true then cageshow.checked=true else cageshow.checked=false)\
catch (messageBox “Must have an editable poly object
selected first.”)
)
on cageshow changed arg1 do ( if arg1 \
then ($.showcage=true) else ($.showcage=false)
)
on actDeactChButton changed arg1 do (
undo off ( – prevents enclosed code from crashing max
– when trying to undy history to the object
– but doesn’t actually affect undo history
– of anything else outside of the paranthesis
– i.e. actual editing history of the
– editable poly is safe
originalss=subObjectLevel –*used so the utility can
– can keep track of user
– subselections
try (
if arg1 then (
OM=($.mesh).numverts
actDeactChButton.caption=“Remove Polylines”
autoupdateChecker.enabled=true
cageshow.enabled=true
updateButton.enabled=true
modPanel.addModToSelection (Edit_Mesh name:“Polylines”) ui:on –*applies editMesh modifier to polyobject
z=copy $.baseObject –*Stores poly info in variable
polyOp.setEdgeSelection z #All –*sets poly edges internally
z.surfsubdivide=$.baseObject.surfSubDivide; –*performs what has happend
z.iterations=$.baseObject.iterations –to the poly object in Max
–to the poly object in the
–variable
y=z.mesh; –*Convert and store the poly object into y
– NURMS Results ‘baked’ into mesh object and as a result
– poly subobject selections are carried over
– as well
yes=getEdgeSelection y – get the mesh edges that are selected
setEdgeSelection $ $.modifiers[“Polylines”] -yes –*Invert selection and apply to
– them to the editMesh modifier
modPanel.setCurrentObject $.modifiers[“Polylines”] –*Make all selected edges in
subobjectLevel = 2 –mesh modifier invisible
meshOps.invisibleEdge $.modifiers[“Polylines”]
subObjectLevel = 0
modPanel.setCurrentObject $.baseObject –*resets the modify panel back to the
subObjectLevel=originalss – the poly object level and user
– subobject selection
showendresult=true –*Places focus at top of the modifier stack so smooth
– polylines will be seen while still at editable poly
– level
)
else(
try(–*this causes the utility to not explode if there isn’t
autoupdateChecker.checked=false
autoupdateChecker.enabled=false
topochecker.active=false
deleteModifier $ $.modifiers[“Polylines”]– a modifer to delete (editMesh)
updateButton.enabled=false
cageshow.enabled=false
actDeactChButton.caption=“Create Polylines”
showendresult=true
subObjectLevel=originalss
)catch( print “Error occured when check button turned off”)
)
)
catch(
messageBox “Select an object that is at it’s
base level an Editable Poly”
deleteModifier $ $.modifiers[“Polylines”]
actDeactChButton.state=false
)
) – undo context end
)– actDeactChButton button end
on updateButton pressed do (
undo off (
originalss=subObjectLevel
modPanel.addModToSelection (Edit_Mesh name:“Polylines”) ui:on
deleteModifier $ $.modifiers[“Polylines”]
z=copy $.baseObject
polyOp.setEdgeSelection z #All
z.surfsubdivide=$.baseObject.surfSubDivide;
z.iterations=$.baseObject.iterations
y=z.mesh
yes=getEdgeSelection y
setEdgeSelection $ $.modifiers[“Polylines”] -yes
modPanel.setCurrentObject $.modifiers[“Polylines”]
subobjectLevel = 2
meshOps.invisibleEdge $.modifiers[“Polylines”]
subObjectLevel = 0
modPanel.setCurrentObject $.baseObject
subObjectLevel=originalss
showendresult=true
)
) – end updateButton button
on closeButton pressed do (DestroyDialog quickOutliner
)– end closeButton
–===============================THIS PART HANDLES THE TOPOLOGY CHECKING AND Auto-UPDATING==========================
on autoupdateChecker changed arg1 do (
if arg1 then (topochecker.active=true;updateButton.enabled=false) else (topochecker.active=false;topoedit.active=false;\
updateButton.enabled=true)
) – end of autoupdateChecker check box
on topochecker tick do (
–print “topochecker, checking…”
if (OM!=($.mesh).numverts) then (topoedit.active=true;topochecker.active=false)
–topochecker.ticks=0
gc()
) – end of mtopopchecker timer
on topoedit tick do (
try(
state1=(mouse.buttonStates[1]==true and (mouse.mode==2 or mouse.mode==1))
state2=(mouse.buttonStates[1]==false and (mouse.mode==2 or mouse.mode==1))
state3=(mouse.buttonStates[1]==true and mouse.buttonStates[3]==true)
–print “topedit checking…”
if state3 then (topochecker.active=true;topoedit.active=false) else (
if (state1 or state2) then () else (–print “update Mesh”
undo off(
originalss=subObjectLevel
modPanel.addModToSelection (Edit_Mesh name:“Polylines”) ui:on
deleteModifier $ $.modifiers[“Polylines”]
z=copy $.baseObject
polyOp.setEdgeSelection z #All
z.surfsubdivide=$.baseObject.surfSubDivide;
z.iterations=$.baseObject.iterations
y=z.mesh
yes=getEdgeSelection y
setEdgeSelection $ $.modifiers[“Polylines”] -yes
modPanel.setCurrentObject $.modifiers[“Polylines”]
subobjectLevel = 2
meshOps.invisibleEdge $.modifiers[“Polylines”]
subObjectLevel = 0
modPanel.setCurrentObject $.baseObject
subObjectLevel=originalss
showendresult=true;
)
OM=($.mesh).numverts;topochecker.active=true;topoedit.active=false)
)
)catch(print “Error occured within topoedit timer”)
) – end of topoedit timer
)
createDialog quickOutliner style:#style_toolwindow width:115 height:125
–End of Script
hi googlo
haven´t tried it yet, but i am sure it works.
maybe there is a solution to maintain the undo history.
really great work
wow googlo good idea with timer
btw here my updated script…
i remove the user interface,
and add options dialog, all
settings store in dat file
check it
— LightWave Smooth Style For 3ds Max5 by 2LoOp <2lp@nm.ru>
— Version 1.8 beta
— Put this script to the 3dsmax5\UI\Macroscripts folder or just
— drag into max viewport, after restart max and go to customize
— menu and under category lptools you find LWSmooth and LWShowCage
macroScript LWSmooth
category:“lptools”
tooltip:“LWSmooth”
buttontext:“LWSmooth”
(
if (selection.count == 1) then (
–read info from store file
fn existFile fname = (getfiles fname).count != 0
_fo=((GetDir #scripts)+”\LWSmooth.dat”)
if not existFile(_fo) then –dat file not exist, create him with default setings
(
_AutoConvert=1
_ShowCage=0
_Interations=2
_SeeThrough=0
_output =_AutoConvert as string + _ShowCage as string + _Interations as string + _SeeThrough as string
_fw=createfile _fp
format _output to:_fw
close _fw
)
_fr=openfile _fo
_ac=readchar _fr –AutoConvert
_sc=readchar _fr –ShowCage
_di=readchar _fr –Derault Interations
_st=readchar _fr –SeeThrough
close _fr
–end read
try (modPanel.getModifierIndex $ selection[1].modifiers[#LWSmooth];_present=true)
catch (_present=false)
if _present then
(
_sobjlvl=subobjectLevel
deleteModifier $ $.modifiers[“LWSmooth”]
$.surfSubdivide = off
showendresult=false
subobjectLevel=_sobjlvl
selection[1].visibility = true
if subobjectLevel !=0 then max select none
)
else
(
if (classof $.baseobject != Editable_Poly) then (
if _ac==“1” then (Try(ConvertTo Selection[1] Editable_Poly)Catch(print”suxx”))
)
if (classof $.baseobject == Editable_Poly) then
(
polyOp.setEdgeSelection $ #All;update $
modPanel.addModToSelection (Edit_Mesh name:"LWSmooth") ui:on
subobjectLevel = 2
if $.iterations == 0 then $.iterations=_di as integer --incrase interations from default zero(if running first time)
-- $.iterations = _di as integer
$.surfSubdivide = on
max select invert
meshOps.invisibleEdge $.modifiers[1]
max select none
modPanel.setCurrentObject $.baseObject
if _sc=="1" then selection[1].showcage = true else selection[1].showcage = false
if _st=="1" then selection[1].visibility = false else selection[1].visibility = true
if subobjectLevel !=0 then max select none
showendresult=true
)else messageBox"Object is not an Editable Poly
and autoconvert to Editable Poly disabled
you can activate autoconvert in options menu”
) –
)–end selection and class check
else (messageBox “Object must be selected” Title:“LWSmooth”)
)
macroScript LWOptions
category:“lptools”
tooltip:“LWOptions”
buttontext:“LWOptions”
(
– byte define
– _ac –AutoConvert
– _sc –ShowCage
– _di –Derault Interations
– _st –SeeThrough
rollout LWOptions “LWSmooth options” width:208 height:176
(
button btn1 “Save” pos:[23,126] width:80 height:24
button btn2 “Cancel” pos:[111,126] width:80 height:24
groupBox grp1 “LWSmooth options” pos:[8,8] width:191 height:158
checkbox ac “Auto Convert to Editable Poly” pos:[21,31] width:170 height:21
checkbox sc “Show Cage” pos:[21,50] width:148 height:20
checkbox st “See-Through” pos:[21,69] width:168 height:22
spinner di “Default Interations” pos:[73,93] range:[0,5,3] type:#integer width:75 height:16
on LWOptions open do
(
fn existFile fname = (getfiles fname).count != 0
_fo=((GetDir #scripts)+”\LWSmooth.dat”)
if not existFile(_fo) then –dat file not exist, create him with default setings
(
_AutoConvert=1
_ShowCage=0
_Interations=2
_SeeThrough=0
_output =_AutoConvert as string + _ShowCage as string + _Interations as string + _SeeThrough as string
_fw=createfile _fp
format _output to:_fw
close _fw
)
_fr=openfile _fo
_ac=readchar _fr –AutoConvert
_sc=readchar _fr –ShowCage
_di=readchar _fr –Derault Interations
_st=readchar _fr –SeeThrough
close _fr
if _ac==“1” then ac.checked=true
if _sc==“1” then sc.checked=true
if _st==“1” then st.checked=true
di.value=_di as integer
)
on btn1 pressed do
(
_di= di.value
if ac.checked then _ac=1 else _ac=0
if sc.checked then _sc=1 else _sc=0
if st.checked then _st=1 else _st=0
_fp = ((GetDir #scripts)+"\LWSmooth.dat")
_output =_ac as string + _sc as string + _di as string + _st as string
_fw=createfile _fp
format _output to:_fw
close _fw
print _output
DestroyDialog LWOptions
)
on btn2 pressed do
(DestroyDialog LWOptions)
)
CreateDialog LWOptions
)
macroScript LWShowCage
category:“lptools”
tooltip:“LWShowCage”
buttontext:“LWShowcage”
(
try (selection[1].showcage=not selection[1].showcage)
catch (messageBox “Operation Failed” Title:“LWShowCage Error”)
)
any one know how change “visibility value” from script?
I thought change is like this selection[1].visibility=0.5 but this does not work…