[Closed] Multiple classes in scripted plugin
Hi everybody!
I want to make a scripted plugin that creates a helper and some geometry objects. (So multiple objects.)
The helper will be the main (parent) object, and it will contains the parameters of the geometry objects.
I know how to make a Helper scripted plugin. I also know how to make a geometry scripted plugin. But I don’t know how to combine these into one SimpleObject scripted pugin. Is it possible?
define both classes in one file (you can do it). if class 2 uses class 1 the class 1 has to be defined first and vice versa.
so you helper plugin can use instance of your geometry plugin to make a mesh for example
Thanks for your answer. But how can I call the create method of class2 plugin from class1?
Edit: Ok, I know how to call it, but can I send parameters to class2 form class1?
Because the class2 will be an invisible plugin, so I have to use the parameters of class1 to create class2.
here is a none optimized sample:
plugin simpleObject Washer name:"Washer"
classID:#(0x00001967, 0xc0c3c99b)
category:"Scripted Primitives"
--invisible:on
(
parameters main rollout:main
(
outer_radius type:#worldunits default:0 ui:ui_outer_radius
inner_factor type:#float default:0.8 ui:ui_inner_factor
height_factor type:#float default:0.1 ui:ui_height_factor
sides type:#integer default:16 ui:ui_sides
)
rollout main "Parameters"
(
spinner ui_outer_radius "Outer Radius: " fieldwidth:60 type:#worldunits range:[0,1e9,0] align:#right offset:[4,0]
spinner ui_inner_factor "Inner Factor: " fieldwidth:60 type:#float range:[0,1,0.8] scale:0.01 align:#right offset:[4,4]
spinner ui_height_factor "Height Factor: " fieldwidth:60 type:#float range:[0,1,0.1] scale:0.01 align:#right offset:[4,0]
spinner ui_sides "Sides: " fieldwidth:60 type:#integer range:[0,256,24] align:#right offset:[4,4]
)
on buildMesh do
(
c1 = createinstance cylinder radius:outer_radius height:(outer_radius*height_factor) heightsegs:1 capsegs:1 sides:sides
c2 = createinstance cylinder radius:(outer_radius*inner_factor) height:(outer_radius*height_factor) heightsegs:1 capsegs:1 sides:sides
mesh = c1.mesh - c2.mesh
)
tool create
(
on mousePoint click do case click of
(
1: nodeTM.translation = gridPoint
2: #stop
)
on mouseMove click do case click of
(
2:
(
outer_radius = amax (abs gridDist.x) (abs gridDist.y)
)
)
)
)
plugin helper WasherPoint name:"WasherPoint"
classID:#(0x00001967, 0xc0c3c99a)
extends:Dummy
category:"Scripted Helper"
replaceUI:on
autoPromoteDelegateProps:on
(
parameters main rollout:main
(
radius type:#worldunits default:0 ui:ui_radius
)
rollout main "Parameters"
(
spinner ui_radius "Radius: " fieldwidth:60 type:#worldunits range:[0,1e9,0] align:#right offset:[4,0]
)
on getDisplayMesh do
(
c = createinstance Washer outer_radius:radius inner_factor:0.5 height_factor:0.3 sides:8
c.mesh
)
on useWireColor do true
tool create
(
on mousePoint click do case click of
(
1: nodeTM.translation = gridPoint
2: #stop
)
on mouseMove click do case click of
(
2:
(
radius = amax (abs gridDist.x) (abs gridDist.y)
)
)
)
)
That was very clear.
Now I understand it perfectly. You helped me a lot.
Thank you
This isn’t the only way to do this and it really depends on what you want to achieve.
For example; if you wanted to create a helper plugin that could create a variety of optional additions, with different types of rollouts, you could use custom attributes instead. Custom attributes, in case you haven’t used them, are basically parameters, rollouts etc. that are structured the same way as a scripted plugin, but that can be used to extend and existing class.