I hate the curveControl UI!!!

Hi, can anyone help me on this?

I put a curveControl UI item in a custom attribute applied to a Morpher modifier.

Then I put a script controller on a morph target so it can be governed by the curveControl. It all works fine until I close and re-open Max, and re-open the scene.

When I reopen the scene the script controller starts complaining that the curveControl is undefined.

I've tried pre-loading the curveControl's properties using the "on load do" handler but again, none of the curveControl's properties become valid until you physically click on the object and go to the modify panel containing the curveControl. Once the curveControl is visible you can re-evaluate the script controller and everything works fine again.

It is DRIVING ME INSANE! There has to be a way to load and access the properties before the curveControl is visible. This thing is the WORST!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

Oh, cool, you're almost there

Oh, cool, you're almost there then. That's an easy. Here is a very very simple example - see the screeen shot.

AttachmentSize
fn_in_scr_cntrl.png 7.27 KB

my recent MAXScripts RSS (archive here)

pacermike's picture

These reply windows keep shrinking!

Almost there! But I can only get it to work when I hard-code the values. As soon as I try to use variables from the scene it starts throwing **unknown system exception** errors.

-- Error occurred in bezierYval()
--  Frame:
--   r2: undefined
--   newPoint: undefined
--   avgSum: undefined
--   xVal: 0.399926
--   p0x: 0.0
--   a: [2.58609,0]
--   d: [0,0]
--   sum: 0
--   r3: undefined
--   c: [2.58609,0]
--   p0y: 0.0
--   p1x: 0.862031
--   p1y: 0.0
--   p2x: 0.0
--   p2y: 0.0
--   p3x: 0.0
--   p3y: 0.0
--   b: [-5.17219,0]
--   percent: #()
--   called in anonymous codeblock
--  Frame:
--   p1: #([0,0], [0,0], [0.862031,0], true, true, false, false, true, false, true)
--   t: 2560.0
--   NT: 0.16
--   thing: undefined
--   x: 0.399926
--   this: Controller:Float_Script
--   curveData: "#(#(true, 3, [0,1], [0,1], #{1..3}, [120.909,120], [-28,-35], #move_xy), #(#("CrazyCakes_x", false, (color 255 0 0), (color 192 192 192), 0, 0, #solid, #solid, 2, 1000), #("CrazyCakes_y", false, (color 0 255 0), (color 192 192 192), 0, 0, #solid, #solid, 2, 1000), #("CrazyCakes_z", false, (color 0 0 255), (color 192 192 192), 0, 0, #solid, #solid, 2, 1000)), #(#(#([0,0], [0,0], [0.862031,0], true, true, false, false, true, false, true), #([1,1], [-0.605639,0], [0,0], true, true, false, false, false, false, true)), #(#([0,0], [0,0], [0,0], true, true, false, false, false, false, true), #([1,1], [0,0], [0,0], true, true, false, false, false, false, true)), #(#([0,0], [0,0], [0,0], true, true, false, false, false, false, true), #([1,1], [0,0], [0,0], true, true, false, false, false, false, true))))"
--   f: 16.0
--   s: 0.533333
--   controlMorph: 39.9926
--   CD: #(#(true, 3, [0,1], [0,1], #{1..3}, [120.909,120], [-28,-35], #move_xy), #(#("CrazyCakes_x", false, (color 255 0 0), (color 192 192 192), 0, 0, #solid, #solid, 2, 1000), #("CrazyCakes_y", false, (color 0 255 0), (color 192 192 192), 0, 0, #solid, #solid, 2, 1000), #("CrazyCakes_z", false, (color 0 0 255), (color 192 192 192), 0, 0, #solid, #solid, 2, 1000)), #(#(#([0,0], [0,0], [0.862031,0], true, true, false, false, true, false, true), #([1,1], [-0.605639,0], [0,0], true, true, false, false, false, false, true)), #(#([0,0], [0,0], [0,0], true, true, false, false, false, false, true), #([1,1], [0,0], [0,0], true, true, false, false, false, false, true)), #(#([0,0], [0,0], [0,0], true, true, false, false, false, false, true), #([1,1], [0,0], [0,0], true, true, false, false, false, false, true))))
--   p2: #([1,1], [-0.605639,0], [0,0], true, true, false, false, false, false, true)
>> MAXScript Script Controller Exception: -- Unknown system exception <<

As you can see from the error readout it looks like everything is working except the for loop, which is no longer collecting any values for some reason ( -- percent: #() ) ???

Man, they sure don't make this easy. Did I mention that I hate the curveControl UI?

I'm attaching a screen shot of my script controller too.

AttachmentSize
scriptcontroller_screeenshot.png 77.79 KB
Anubis's picture

Maybe need to start reply on top

This for-loop kill the whole function. With empty array the line: "avgSum = sum / percent.count" is evalueted as dividing zero by zero that for sure is a system exception.

Realy strange... the for-loops itself works fine in script controllers...

my recent MAXScripts RSS (archive here)

pacermike's picture

Sigh :(

Ok, so here's the workaround for anybody following along.

First, let me just say that the curveControl... is garbage. Unless there's some secret way to use it so it's not the most cumbersome, user-UNFRIENDLY, Satanic demon-spawn of a system I've ever used then I'd have to say whoever is responsible for it should face some swift criminal charges. Seriously, it is a joke. I have been sitting at my computer for 3 solid days trying to figure out this one stupid thing: How to load a scene without breaking my script controllers.

Any object that I can think of that would use a curve would become dependent on that curve for guidance, so why it is that you must physically "activate" the curve before the scene will recognize that it even exists, despite it's data being permanently stored in a param block is beyond me. It makes it virtually impossible not to break the scene, right? This thing was written back in 1999 according to the SDK so how can more than a decade later it still be so freaking clunky and poorly implemented that regular people can't make any use of it?

So ANYWAY... the big genius fix for this is the following:
In the "on load do" handler of your custom attributes you create a function

fn rollOutAdder = 
	(
		curveFloater = newRolloutFloater "Curve Control Test" 500 400
		addRollout xyzSplit curveFloater	
	)
 
rolloutAdder()

This forces the curveControl on to a floater so it becomes visible and initializes before the script controller has a chance to complain about it.

The bad news of course is that the rollout can't exist in two places at once so as long as it's in the floater it can't be in your modify panel. Once you close the floater though, it will put itself back in the modify panel where it belongs. Once it's back on the modify panel it can't be detached again though, so it's an extremely cheesy fix and I would be surprised if it didn't open the door to a whole host of other problems.

My advice to anyone reading: Don't use the curveControl. Ever. For anything. It is WAY more trouble than it's worth and I despise it with a deep, religious zealotry for the days it's stolen from me. Because of it I doubt the tool I'm writing will ever be stable enough to use or distribute to anyone else.

If anyone knows of a way to make the curveControl not suck, please share. I'll take back everything I ever said. I just can't believe that any UI element could be this tortuous to use when all the others are so simple by comparison???

Anubis's picture

Maybe the problem is in the

Maybe the problem is in the script controller. Until the file is open you can select/deselect w/o errors? And has error only in new session? If so, looks like your script controller not access directly to the Custom Attributes but via some temp variable.

my recent MAXScripts RSS (archive here)

pacermike's picture

Hi Anubis,

Here's the expression I'm using in the Script Controller:

(getValue $box01.morpher.morphTools.xyzSplit.controls[8].curves[1] 0 (controlMorph/100))*100

getValue is a curveControl method

morphTools is the custom attribute
xyzSplit is the rollout
controls[8] is MAXCurveCtl:cc_spltChnls.

Then I have the variable controlMorph assigned to:
Target:$box01.modifiers[#Morpher].'[2] CrazyCakes (Target Available)'

The Script Controller loses it's connection to the curveControl whenever I close Max and reopen the scene AND whenever I redefine the custom attribute.

I attached the files in case you had a few minutes to check them out. When you open the Max scene the script controller should immediately throw an error. Select box01, go to the modify panel then click evaluate on the Script Controller and it will work again.

Thanks for any ideas :)

AttachmentSize
morphbasecompare_curvecontrol07_preload_curves.ms 17.64 KB
morphscript_testscene_loadtest.max 288 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.