(API) Edit in new window

(API) Edit in new window

Anonymous
Not applicable
1,463 Views
5 Replies
Message 1 of 6

(API) Edit in new window

Anonymous
Not applicable

Hi all,

 

I'm trying to create a function using the API (in C#) to open the current selection of elements in a new window (hiding all others). Similar to the function of button in the snip below?Capture.PNG

Thank you!

0 Likes
Accepted solutions (1)
1,464 Views
5 Replies
Replies (5)
Message 2 of 6

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @Anonymous 

 

Example code

    Dim viewRobot As IRobotView3
    
    Dim Rsel As RobotSelection
    Set Rsel = RobApp.Project.Structure.Selections.Create(I_OT_BAR)
    Rsel.FromText "3"
    
    Set viewRobot = RobApp.Project.ViewMngr.CreateView(I_VT_STANDARD)

    viewRobot.Selection.Set I_OT_BAR, Rsel
    viewRobot.Visible = True
    viewRobot.Redraw (0)
    RobApp.Project.ViewMngr.Refresh
    


Rafal Gaweda
0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Rafal,

 

Sorry for the slow response, I've been busy! I've tried this out, but it doesn't quite replicate the function. I've included a screen capture of the results. On the left, there is the full model, middle is the result of the function you suggested, and on the right is the desired outcome. It seems that the script you've given me isolates that bar, but leaves all nodes and panels intact. Could you suggest a way to get round that? Is there also a way of copy the view parameters (i.e. section shapes etc) from the original view and applying them to the new view?

 

I've also included a snip of my exact code which I've done my best to translate into C# for my uses (barsSelect is the selection of bars).

 

Thanks!

0 Likes
Message 4 of 6

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution

Hi @Anonymous 

 

You have to make additional selections and add it \ them to window

Example

 

    Dim NodeSelection As RobotSelection
    Set NodeSelection = RobApp.Project.Structure.Selections.Create(I_OT_NODE)
    NodeSelection.FromText "1 2 3 4"

...
viewRobot.Selection.Set I_OT_NODE, NodeSelection
viewRobot.Selection.Set I_OT_BAR, Rsel
...

 

 

 



Rafal Gaweda
0 Likes
Message 5 of 6

Anonymous
Not applicable

Brilliant, thank you!

0 Likes
Message 6 of 6

lukasz_koc1
Contributor
Contributor

Did you ever encounter a problem that Claddings are not hiding? Everything other hides correctly but claddings stay visible. 

import clr
clr.AddReferenceToFileAndPath("C:/Program Files/Autodesk/Autodesk Robot Structural Analysis Professional 2019/System/Exe/Interop.RobotOM.dll")
from RobotOM import *
from System import Object

application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
objects = structure.Objects
application.Interactive = False
groupNumb = structure.Groups.GetCount(IRobotObjectType.I_OT_BAR)
allgroups = [structure.Groups.Get(IRobotObjectType.I_OT_BAR,x) for x in range(1,3)]

nodeSel = project.Structure.Selections.Create(IRobotObjectType.I_OT_NODE)
nodeSel.Clear()
project.Structure.Selections.Create(IRobotObjectType.I_OT_OBJECT)
panelSel = project.Structure.Selections.Create(IRobotObjectType.I_OT_PANEL)
panelSel.Clear()
FESel = project.Structure.Selections.Create(IRobotObjectType.I_OT_FINITE_ELEMENT)
FESel.Clear()
allSel = structure.Selections.CreateFull(IRobotObjectType.I_OT_OBJECT)
allSel.Clear()

backLog = []

for barSelection in allgroups:
    viewRobot = project.ViewMngr.CreateView(IRobotViewType.I_VT_STANDARD)

    newSel = project.Structure.Selections.Create(IRobotObjectType.I_OT_BAR)
    newSel.FromText(barSelection.SelList)
    
    
    viewRobot.Selection.Set(IRobotObjectType.I_OT_NODE, nodeSel)
    viewRobot.Selection.Set(IRobotObjectType.I_OT_PANEL, panelSel)
    viewRobot.Selection.Set(IRobotObjectType.I_OT_FINITE_ELEMENT, FESel)
    viewRobot.Selection.Set(IRobotObjectType.I_OT_OBJECT, allSel)
    
    viewRobot.Selection.Set(IRobotObjectType.I_OT_BAR, newSel)
    viewRobot.Visible = True
    viewRobot.Title = "LOOL"
    backLog.append(barSelection.Name)
    viewRobot.Redraw(0)


application.Interactive = True
OUT = allSel.Count

  @Rafal.Gaweda Could you probably help? 

0 Likes