How to add a new shapre frame with code?

How to add a new shapre frame with code?

diana_ceballos6XXWT
Participant Participant
177 Views
1 Reply
Message 1 of 2

How to add a new shapre frame with code?

diana_ceballos6XXWT
Participant
Participant

I have a model with a lot of 3D details, and I am trying to add a second shape frame for all the objects. I want to use that frame as a "work view" and later switch back to the original frame. I attempted to add a subnode to the visuals > IndexShape node and a "frame" node to the object visuals, but it doesn't seem to be working.

 

Object obj = Model.find("Processor4");
treenode newnode = Model.find("Processor4").find(">visual/shapeindex").subnodes.add();
newnode.value=1;
 
treenode x = Model.find("Processor4").find(">visual").subnodes.assert("frame",0);
return x;

 

Is it possible to add that new frame just with code or the only way is to do it from the properties?

0 Likes
178 Views
1 Reply
Reply (1)
Message 2 of 2

FelixMoehlmann
Collaborator
Collaborator

You can 'explore' the structure of the GUI to find what code is executed when you press the button to add a new shape to an object.

Screenshot 2026-03-24 082519.png

You can mostly use the code as is. One the "objectFocus" and "shapeFocus" nodes need to be defined differently. Those point to the "shape" node and the currently active shape (which is either the shape node itself or a subnode of it).

Object owner = Model.find("Queue1");
treenode objectFocus = shape(owner);
treenode shapeFocus;
int frameIndex = owner.find(">visual").subnodes.assert("frame", 0).value;
if(frameIndex == 0) {
	shapeFocus = objectFocus;
}
else {
	shapeFocus = objectFocus.subnodes[frameIndex];
}
0 Likes