Problem to name subobjects in js/nodeeditor

Next
 From:  Karsten (KMRQUS)
7899.1 
Hello Michael,
I try to name naked Edges of a sweep - also the sweep itself. It seems that it is working - a cloned object that is added to the DB has the right name. If I apply the sweep-surface to the DB (apply button) it is named, but the naked edges are still unnamed.
Here is the code-fragment. I have marked the relevant lines with "///////////////////////////////////////////"


var factory = moi.command.createFactory('sweep');
factory.setInput(0, inProfiles);
factory.setInput(1, Rails);
factory.setInput(4, this.properties.pointy_ends); //Pointy ends
factory.setInput(5, this.properties.Twist); //Twist
factory.setInput(7, cap_ends); //Twist
var output = factory.calculate();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
output.item(0).name=this.properties.edgeName;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
for (var i = 0; i < output.item(0).getNakedEdges().length; i++)
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
output.item(0).getNakedEdges().item(i).name = this.properties.edgeName + "_E" + i;
this.tempObjects.addObject(output.item(0).getNakedEdges().item(i).clone());
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
moi.geometryDatabase.addObjects(this.tempObjects); // throwing the Objects to the database, so they are selectable!!!
if (this.properties.visible == 'false')
for (var i = 0; i < this.tempObjects.length; i++)
{
this.tempObjects.item(i).hidden = true;
}
this.setOutputData(0, output);
factory.cancel();

Is it possible at all?

Have a nice day
and thanks in advance!
Karsten
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
7899.2 In reply to 7899.1 
Hello Michael,
is it possible that clone don't copy the names of subelements?
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7899.3 In reply to 7899.2 
Hi Karsten,

re:
> is it possible that clone don't copy the names of subelements?

Yeah I think that is what's happening. The way the sub-element properties work is that some attribute data needs to be prepared on the internal geometry library surfaces and edge curve objects, and then when the geometry library Brep object is duplicated it will look for those attributes and read the MoI-specific properties out from them.

This attribute preparation happens automatically for anything that goes through a geometry factory, but it's not happening if you directly call obj.clone(). I will put in a fix for that in v4 but for now instead of calling obj.clone(), try using the copy geometry factory and it should avoid that problem.

Something like:

var factory = moi.command.createFactory( 'copy' );
var origin = moi.vectorMath.createPoint(0,0,0);

factory.setInput( 0, objectlist );
factory.setInput( 1, origin ); // The "Base point" for the Transform > Copy command.
factory.setInput( 2, origin ); // The "Target point" for the Transform > Copy command.

var result_list = factory.calculate();


- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7899.4 In reply to 7899.2 
Hi Karsten, except I think the problem I see is with cloning an entire BRep - but you're cloning an edge curve there, right, not an entire brep?

I would think that curve cloning should preserve the object name of the edge curve. I'll need to get a running example set up over here to see.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
7899.5 In reply to 7899.3 
Hello Michael,
thanks for your reply. I will try to find a workaround:-)

Have a nice day
Karsten
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7899.6 In reply to 7899.1 
Hi Karsten, here's what I did to test clone on edges - I made a plane and named its edges A, B, C, D.

Then I pasted in this script to the XYZ control:

script: var breps = moi.geometryDatabase.getSelectedObjects().getBReps(); for ( var i = 0; i < breps.length; ++i ) { var edges = breps.item(i).getNakedEdges(); for ( var j = 0; j < edges.length; ++j ) { var newcrv = edges.item(j).clone(); moi.geometryDatabase.addObject( newcrv ); } }

The edges are cloned into separate curve and those curves seem to have inherited the name of the edge ok...

Are you using .clone() somewhere else on a brep instead of a curve possibly?

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
7899.7 In reply to 7899.4 
Hello Michael,
the output node uses clone and after an Apply the edges are unnamed - name of the brep is ok.

The tempobjects are only for preselections in a running nodeeditor for creating new nodes - I want only
evaluate the names and store them in the node. After connecting the brep data I want to
select the naked edges by the stored names for e.g. blend-nodes.
I will send You the complete code
next friday, because I am not at home.
And I have to investigate the input/output functions -
maybe the names are still present in the direct following node, but first I have to create a testnode.

Thanks in advance
Karsten
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7899.8 In reply to 7899.7 
Hi Karsten,

re:
> the output node uses clone and after an Apply the edges are
> unnamed - name of the brep is ok.

Ok yeah if it's a Brep being cloned then I think there is a problem in there with sub-object atttributes not coming through. I've got it fixed for v4 but for now try using the copy factory from above to duplicate the Brep instead of clone().

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
7899.9 In reply to 7899.8 
Hello Michael,
I have made a testnode to check the chain "this.setOutputDatata"-> "this.getInputData" from one node to another. The inputdata are complete available - including named subobjects. So I can use this method to select named subelements for a blendnode:-)
When I have finished the node, I will post it to the forum.
By the way: What is the index 1 -|>Orientations in the blend factory for? And what are the parameters? I didn't find something in the blend.js that helps me.

Thank You very much for your help!

Have a nice day
Karsten
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
7899.10 In reply to 7899.9 
Datata has an extra ta ?
-B
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
7899.11 In reply to 7899.10 
Hello Brian,

it is only the increase form of data;-) -> datata -> datataest

Have a nice day
Karsten
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
7899.12 In reply to 7899.9 
Hi Karsten,

> By the way: What is the index 1 -|>Orientations in the blend factory for? And what
> are the parameters? I didn't find something in the blend.js that helps me.

When you do a blend, the blend factory will fill that in itself, it stores 2 flags for each blend side, a "flipped" flag for whether the side should be flipped from its natural orientation, and a seam parameter for where the seam point should be located on a closed blend.

Those are then stored in the factory input so they will get serialized into history data and a history update will use any customized seam locations that were set by the user inside the Blend command.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All