3DS MAX: 3ds Max Forum 3ds Max Tutorials

Maxscript - Delete spline segments not working inside functions

COW Forums : Autodesk 3ds Max

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Niculae RazvanMaxscript - Delete spline segments not working inside functions
by on Feb 22, 2013 at 1:52:29 pm

Goal: Create a quarter of an ellipse, and elevate one of its points.
I’ve manage to make it work, but inside a function, everything falls apart.
Obviously from the code that I’m a beginner, so this is it:
Delete $*
clearlistener ()
function test var1 =
(
Ellipse adaptive: true length:10 width:var1 pos:[0,0,0] name: "s"
convertToSplineShape $s
updateshape $s
Select $s
modPanel.setCurrentObject $s.baseObject --this line is optional
subobjectLevel = 2
setSegSelection $s 1 (#(1,3,4)) --keep: false –delete all except second quadrant

splineOps.delete $ --everything is ok until now

--actionMan.executeAction 0 "40020" -- worked for a while, then it started to delete the entire shape
subobjectLevel = 0 --this is where everything goes berserk, I tried "=2" as well, still not working.
updateshape $s
--clearselection()

addmodifier $s (Spline_IK_Control helper_size: 0.5 linkTypes: 2 box:off helper_cross: on wirecolor: yellow)
updateshape $s
$s.spline_ik_control.createHelper ($s.spline_ik_control.getKnotCount())
clearselection()
move $Point001 [0,0,10] --point repositioning not working on the second run of the code
$Point001.pos.z =10 --not working either when the code is run second time
)

test 20

Point repositioning in the last lines at first they did not work, then it started again but point002 start to move as well, then it only worked after the second execution of the code in a fresh environment. I feel like I’m in the Twilight Zone...
at line
subobjectlevel = 0
after the splineops.delete $
command, the segments reappear as if the delete command did not took hold. Like it was a temporary delete of somekind. I've tried resetshape, updateshape, clearselection, and many things in different arrangements. Is there a command like „clear and empty all variables and reset the entire environment for a fresh start” to place at the start of the code? What am I missing here?
My guess is that I'M NOT EXITING FROM THE SUB-OBJECT EDITING MODE PROPERLY and thus the results are not embedded and printed out of from the shape cache or something. And probably that is why the final repositioning of a spline IK point is not working properly, since I’m still in a somekind of a sub-object editing mode.

Autodesk 3dsMax 2013 64-bit version 15 product update 6
Acer aspire V3-571G-53214G50Makk, Ivy Bridge Core i5-3210M @ 2.5GHz(turbo boost 3.1GHz), Nvidia GeForce GT 630M (2GB VRAM), 8 GB RAM DDR3 1333MHz, Win 7 Ultimate 64-bit


Return to posts index

Joseph W. BourkeRe: Maxscript - Delete spline segments not working inside functions
by on Feb 22, 2013 at 7:37:47 pm

Hi Niculae -

I once again apologize for not have the technical knowledge to help you, and I was going to point you to the Area, but I see you've already checked in there. There's one more place I will point you to that may be of help:

http://forums.cgsociety.org/forumdisplay.php?f=98

There seems to be some fairly technical discussion going on - I hope they can be of help.

Joe Bourke
Owner/Creative Director
Bourke Media
http://www.bourkemedia.com


Return to posts index


Niculae RazvanSolution!
by on Feb 22, 2013 at 10:33:49 pm

Thanks to forum user gazybara on cgsociety.org apparently I have to “open” the spline before I attempt any operations on it. I didn’t know that. I have learned something new today.
Deleting knots and not segments is indeed far more efficient, and resetting the numbering of the first knot is indeed brilliant if in future developments of the code I intend to use a for loop to delete them.
I’m interested in repositioning ONLY ONE of the remaining 2 points in the spline, therefore my final code, and what I was really after, basically looks like this:
fn my_fct =
(
spl = convertToSplineShape(Ellipse adaptive: true length:10 width:20 pos:[0,0,0] name: "s")
open spl 1
deleteKnot spl 1 1
deleteKnot spl 1 3
setKnotPoint spl 1 1 [0,5,2]
updateshape spl
)
my_fct()


Autodesk 3dsMax 2013 64-bit version 15 product update 6
Acer aspire V3-571G-53214G50Makk, Ivy Bridge Core i5-3210M @ 2.5GHz(turbo boost 3.1GHz), Nvidia GeForce GT 630M (2GB VRAM), 8 GB RAM DDR3 1333MHz, Win 7 Ultimate 64-bit


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]