« Back

Group/Combine Model Elements in Modelling Editor

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Group/Combine Model Elements in Modelling Editor
interref adoxx combine
Answer
1/9/19 1:26 PM
Hello,

Is there a possiblity to group model elements together,
so  if element A  is moved the model element B is also moved in the modeling tool.


To make this more clear here my example:
i have following model concepts (see picture):
- Component 
- Pin

If i place now the Componet  in the modeling tool automaticly 2 Pins beside the model element Component are created.
Now i also need a possibilty to link the Pin to the Component so that when i move the Component the Pin is also moved. 

To have also the logical linke between this model elements a model INTERREF is used.

Thank you for your help!

BR
Martin

(ADOxx Verson 1.5)
Attachment

Attachments: pin_example.PNG (1.1k)

RE: Group/Combine Model Elements in Modelling Editor
interref if get_class_name get_class_id attribute adoscript expression attribute type get_attr_val
Answer
10/4/18 12:37 PM as a reply to Martin Paczona.
The easiest way to move the Pin objects when moving the corresponding Component object is to select the Pin objects together with the Component object. You can either do this manually by selecting all the objects when you want to move them or you can do this e.g. via a Script which, when executed, selects the Pin objects connected via INTERREF with the selected Component object.

Regarding the Script:
1) Create an attribute of type “EXPRESSION” with the name e.g. “PinsInterrefIDs” for the class Component

2) Add the following Expression to the standard value of the PinsInterrefIDs attribute:
EXPR type:string expr: (irtobjs("#Name of the INTERREF attribute which connects the Pins with the Component object#")) → e.g. EXPR type:string expr: (irtobjs("Pins"))

3) AdoScript code: What the following script basically does is
a) it gets all the IDs of selected objects in an active model
b) it loops through the list with the IDs and because only the selected Component objects are relevant in this case it checks for the objects of class Component
c) For the selected Component objects it gets the IDs of the Pins objects, which are connected via INTERREF with a selected Component object, into an array
d) it loops through the array to select all the Pins objects

 1CC "Modeling" GET_ACT_MODEL
 2# --> RESULT modelid:intValue
 3SETL nModelID:(modelid)
 4
 5CC "Modeling" GET_SELECTED modelid:(nModelID)
 6# --> RESULT ecode:intValue objids:strValue classid:id
 7SETL sSelectedObjects:(objids)
 8
 9#Create an array for the Pins objects IDs
10SETL aPinsObjects:({})
11
12FOR i from:(0) to:(tokcnt(sSelectedObjects)-1) {
13
14  #check for the selected objects of Class Component in case
15  #there are more objects of different classes selected at once
16  CC "Core" GET_CLASS_ID objid:(VAL (token(sSelectedObjects,i)))
17  #--> RESULT ecode:intValue classid:intValue isrel:intValue
18  CC "Core" GET_CLASS_NAME classid:(classid)
19  #--> RESULT ecode:intValue classname:strValue isrel:intValue
20
21  #in case a selected object is of class Component then get
22  #the IDs of the connected (via INTERREF) Pin objects and put them
23  #into the array aPinsObjects
24  IF (classname = "Component") {
25    CC "Core" GET_ATTR_VAL objid:(VAL (token(sSelectedObjects,i))) attrname:("PinsInterrefIDs")
26    #-->RESULT ecode:intValue val:anyValue
27    FOR j in:(val) {
28      SETL dummy:(aappend(aPinsObjects, VAL j))
29    }
30  }
31}
32
33#select all the Pins objects belonging to selected Component objects
34FOR i from:(0) to:(aPinsObjects.length - 1) {
35  CC "Modeling" SELECT objid:(aPinsObjects[i])
36  # --> RESULT ecode:intValue .
37}