I am trying to translate the whole structure using the API.
My initial idea was to select all nodes with `Structure.Nodes.CreateFull()` and then use `Structure.SelTranslate` but this doesn't translate any of the nodes.
So far the workaround I found is to iterate over the selection and move all nodes one by one with `Structure.TranslateNode`. This takes a long time however.
Is there a way to translate all nodes at once?
Solved! Go to Solution.
Solved by Rafal.Gaweda. Go to Solution.
It works on selection "in Robot" - by Get.
Example:
Set sel = RobApp.Project.Structure.Selections.Get(I_OT_NODE)
sel.FromText "All"
RobApp.Project.Structure.Edit.SelTranslate 15, 0, 0, I_TO_COPY, 1
Thanks @Rafal.Gaweda it works indeed. What is the difference between `CreateFull` and `Get` + `FromText('all')`?
I find the API reference a bit obscure when it comes to selections.
Create... methods create selections in API to work with API. These selections are not visible in Robot.
Get - get selections from Robot \ model. You can Get even empty selection and the fill it as You like.
NOTE: playing with selections Got from Robot may be more time consuming as Robot will refresh them (display of them) on display \ model.
So
Dim sel As RobotSelection
Set sel = RobApp.Project.Structure.Selections.Get(I_OT_NODE)
sel.FromText "All"
gives the same effect as
Dim sel As RobotSelection
Dim sel1 As RobotSelection
Set sel = RobApp.Project.Structure.Selections.CreateFull(I_OT_NODE)
Set sel1 = RobApp.Project.Structure.Selections.Get(I_OT_NODE)
sel1.FromText sel.ToText
or
Dim sel As RobotSelection
Dim sel1 As RobotSelection
Set sel = RobApp.Project.Structure.Selections.CreateFull(I_OT_NODE)
Set sel1 = RobApp.Project.Structure.Selections.Get(I_OT_NODE)
sel1.Clear
sel1.Add sel
Thanks for the explanation @Rafal.Gaweda, that makes perfect sense. I wish there was a few examples like this in the documentation.
Dear all,
How to combine nodes and bars in the same selection?
Thanks a lot
@Anonymous
What are you trying to achieve? You may have better luck posting a new question.
If your problem is related to translating elements in the structure, moving the nodes will move the bars too since the bars are defined with a reference to the start/end node numbers.
Thanks @JacquesGaudin ,
My issue is in SelRotate command (similar than SelTranslate).
The thing is when I rotate my structure by selection of nodes, all bars are translated properly but the Gamma angle is not changed (is the same value than with no rotation), therefore I need rotate all my nodes and bars at the same time, so that this gamma is updated.
I've tried it with I_OT_OBJECT and the process is OK, but there are some isolated node that is not rotated.
Thanks for your comments.
If I remember correctly, ``SelRotate`` operates on the selection in Robot's window (the one you can actually see on the screen) which is a IRobotMultiSelection. The following should work to select bars and nodes and apply a rotation to them.
Set selNode = RobApp.Project.Structure.Selections.Get(I_OT_NODE)
selNode.FromText "All"
Set selBar = RobApp.Project.Structure.Selections.Get(I_OT_BAR)
selBar.FromText "All"
SelRotate p0x, p0y, p0z, p1x, p1y, p1z, angle, options, repetitions
Thanks a lot @JacquesGaudin it works perfectly.
I was thinking that when the bars are selected the selection of nodes was lost.
Thank you.
Can't find what you're looking for? Ask the community or share your knowledge.