CMB6 - New Resource operateInternal()


Hi Guys,

I am trying to create resource from File -> New Resource -> Malone. I am able to open the dialog box, populate the dialog box but when I click apply I am not able to use the operateInternal() function. IE I am unable to access the operator in the session. I can’t do a simple print and get the value for instance. It works through the operator panel.




Hi Corey,

If you are able to select Malone from File->New Resource, then I am guessing you have written a Malone bridge and provided a create() operation for this resource type. Awesome!

Without seeing the internals of your create() operation, my first guess would be that the operation’s operateInternal() method is not returning the right thing. As an example, let’s look at the last few lines of operateInternal() in smtk::bridge::mesh::Read():

  Result result = this->createResult(smtk::operation::Operation::Outcome::SUCCEEDED);

    smtk::attribute::ResourceItem::Ptr created = result->findResource("resource");

  return result;

This code works in tandem with the description code for smtk::bridge::Read::Result:

    <AttDef Type="result(read)" BaseType="result">

        <Resource Name="resource">
            <Resource Name="smtk::bridge::mesh::Resource"/>

        <Void Name="allow camera reset" IsEnabledByDefault="true" AdvanceLevel="11"/>

Registering a create operation implies (with no documentation yet, sorry!) that the operation will return a resource in its result.

Hope this helps!



Also, to print something in an operation’s operateInternal and have it show up in ModelBuilder’s output window you must use the operation’s logger (accessible within operateInternal() via this->log()).


Hi TJ,

Thanks for the quick reply.

We do that with the python code below:

rsrc = cheers.malone.Resource.create()
# Assign malone session to malone resource
sess = cheers.malone.Session.create()
result = self.createResult(smtk.operation.Operation.Outcome.SUCCEEDED)
created = result.findResource("resource")
return result

The SBT Code looks like:

<AttDef Type="result(set working directory)" BaseType="result">
                <Resource Name="resource" Label="malone">
                        <Resource Name="cheers::malone::Resource"/>

This is still not working.



All is working now as described above in SMTK as of this commit.