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.

Thanks,

Corey

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");
    created->setValue(resourceItem->value());
  }

  return result;

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

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

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

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

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

Hope this helps!

Sincerely,
T.J.

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()
rsrc.setSession(sess)
result = self.createResult(smtk.operation.Operation.Outcome.SUCCEEDED)
created = result.findResource("resource")
created.setValue(rsrc)
 
return result

The SBT Code looks like:

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

This is still not working.

Thanks,

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