Notifications
Clear all

[Closed] Bobo's "fast tool development" video

That’s odd. I comment out parts of the code like this


local owner -- = if owner != undefined do owner

My listener says


>> MAXScript Rollout Handler Exception: -- Unknown property: "dialogWidth" in undefined <<
>> MAXScript Rollout Handler Exception: -- Unknown property: "dialogWidth" in undefined <<

According to the code logic, if owner is undefined “do owner” will not execute. So logically, there are no difference before and after I comment out these codes.
I am lost. Ha~.

What about this error ?
It seems that you cannot use nested structs with this tool design. Try this:

global genericGlobal
(
    struct genericTool
    (
        Element =
        (
            struct Element ( member )
        ),

        ElementArray =
        (
            struct ElementArray ( objs = #(Element) )
        ),

        testArray = #(),

        on create do
        (
            print (ElementArray());
        )
    )
    genericTool();
)

Denis, have you ever had this kind of problems ?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

there is no problem in your sample. it looks just as wrong definition for me. here is how i would do the same:


global genericGlobal
(
	struct genericTool
	(
		Element =
		(
			struct Element ( member )
		),

		ElementArray =
		(
			struct ElementArray ( objs = #() )
		),

		testArray = #(),

		on create do
		(
			print (ElementArray objs:#(Element));
		)
	)
	genericTool();
)

but it doesn’t make sense for me to have a struct definition (Element) as array item instead of have its instance.

but it doesn’t make sense for me to have a struct definition (Element) as array item instead of have its instance.

In that simple case, I agree with you. It was only a short snippet to highlight the nested structs design. The array is a bad idea there because it often starts empty…

This following snippet might be more the problematic case:

global genericGlobal
(
	struct genericTool
	(
		Element =
		(
			struct Element (member)
		),
		
		NestedElement = 
		(
			struct NestedElement
			(
				nested = Element(),
				anotherMember
			)
		),
		
		testArray = #(),
		
		on create do
		(
			local test = NestedElement();
			print test
		)
	)
	genericTool();
)

This kind of nested definition can occur often enough, in my opinion.

I wanted to know if there was any workaround for that. This kind of structure definition works when the struct are not nested under one single struct.

Edit: Obviously, you could fill the “nested” property each time you create one instance of the NestedElement() struct but it is a pain…

here is a workaround:

global genericGlobal
(
	struct genericTool
	(
		NestedElement = 
		(
			struct NestedElement
			(
				Element =
				(
					struct Element (member)
				),
				nested = Element(),
				anotherMember
			)
		),
		
		testArray = #(),
		
		on create do
		(
			local test = NestedElement()
			print test
		)
	)
	genericTool()
)

Ok… I still think it is quite dirty because you need to declare the Element struct as many times as you want to nest it into another struct but… it is a workaround !

i’m not sure that you clear understand how structs and struct definitions works…
there is another way to do want you want:

global genericGlobal
(
	struct Element (member)
	struct genericTool
	(
		NestedElement = 
		(
			struct NestedElement
			(
				nested = Element(),
				anotherMember
			)
		)
	)
	genericTool()
)

use nested structs where they work…

We agree on that last one !
I ended up with that, too.

At first, I was trying to declare all my structs inside the genericTool struct because I don’t use (at the moment…) the big global encapsulating brackets design (cf. my posts earlier).
So, to avoid having my structs declared as global, I was looking for a way to embed their declarations in my tool struct.
Then I hit this nested definition problem…

Anyways, thanks for the quick answers Denis
I think it is time to convert myself to the global encapsulation religion :wise:

Page 2 / 2