Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Object Oriented Programing: Include a rollout as a member?

Object Oriented Programing: Include a rollout as a member?

Anonymous
Not applicable
238 Views
2 Replies
Message 1 of 3

Object Oriented Programing: Include a rollout as a member?

Anonymous
Not applicable
Try this one:

struct trafficLine
(
name = "the name of the type",
info = "some describ",
image = "a preview image path",
width = 0.15,
length = 4.0,
spacing = 2.0,
guideLine = #(),
Poly = #(),
fn makePoly =
(
if isValidNode poly and poly != undefined do delete poly
tempPart = plane width:width length:length
Poly = MakeStripPoly guideLine tempPart spacing 0.5 off --To make the test work, this line may be replaced by "poly = plane( )".

delete TempPart

poly
),

fn resetGuideline =
(
guideLine = undefined
),

fn resetPoly =
(
poly = undefined
),

panel = rollout panel name
(
button apply "apply"
on apply pressed do makePoly()
),

fn makePanel =
(
try destroyDialog panel catch()
createdialog panel
)
)

a = trafficLine ()
a.guideline = circle()
a.makePanel()



well, it's all fine till you press the botton "apply".

I"m trying to make the UI defination as part of the object, is that possible?


(In fact, I've already solved this case in another way: I create a rollout outside the struct defination and a initiallizePanel( ) inside.)
0 Likes
239 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Did you try passing in the instance of a trafficLine to the makePanel function? The following 'create, then initialize' worked for me


struct trafficLine
(
-- <same original stuff>

panel = rollout panel name
(
button apply "apply"
local makePolyFn = undefined
on apply pressed do if (classof makePolyFn == MAXscriptFunction) then makePolyFn()
),

fn makePanel owner =
(
try destroyDialog owner.panel catch()
createdialog panel
panel.makePolyFn = owner.makePoly -- initialize the panel
)

)

a = trafficLine()
a.guideline = circle()
a.makePanel(a) -- Pass in the owner, sorta like a 'this" argument...

0 Likes
Message 3 of 3

Anonymous
Not applicable
Nice! I hadn't tried assigning it to a member. Thanks for that.
0 Likes