Notifications
Clear all

[Closed] Access base class parameters of script extended class from c++ ?

Hi all,

                   I’ve been trying to access the paramblock of a child class deriving from a simple object like sphere. Something like this 

                                         plugin geometry testSphere
                    name:"test sphere”
                    category:"test"
                    classID:#(0x13456, 0x12468)
                    extends:sphere
                    replaceui:true
                    (
                    )                     

                                         and from c++                     

                                         Interface* ip = GetCOREInterface()                     

                                         Object *obj = (Object*) ip->CreateInstance(GEOMOBJECT_CLASS_ID, Class_ID(0x13456, 0x12468))                     

                                         char* toto = obj->GetObjectName() // name is correct                     

                                         // Get a hold of the parameter block
                    IParamArray * params = obj->GetParamBlock()
                    assert(params)                     

                                         The param block will be null.                     

                                         I’m trying to access SPHERE_RADIUS and others parameters from c++ to create objects like I want                     

                                         Thanks !
3 Replies

try:
IParamBlock2* pBlock2 = obj->GetParamBlock(i);
“i” you have to figure out, think its 0 in your case

then:
int pid_radius = obj->GetParamBlockIndex(SPHERE_RADIUS);
float sphereRadius = 0.0f;
pBlock2->GetValue(pid_radius, 0, &sphereRadius);

or something like that…

guruware

IParamBlock2* GetParamBlock(int i)

Is defined from Animatable, so I can’t access it from Object

I tried to cast into a Animatable* but I suppose life isn’t that easy :rolleyes:

Solved it !

if you do

plugin geometry testSphere
name:”test sphere”
category:“test”
classID:#(0x13456, 0x12468)
extends:sphere
replaceui:true
(
parameters basic
(
radius type:#float default: 0.0
segs type:#float default: 0.0

    on radius set val do
    (
        delegate.radius = val
    )
    
    on segs set val do
    (
        delegate.segs = val
    )
)
                     )                     

You’ll have a paramblock that you can access from Object