(API) New Window

chjpcoi
Advocate
Advocate

(API) New Window

chjpcoi
Advocate
Advocate

Hello everyone

I create a new view and want to select some elements from the original view to the new view. But I have the problem that other unselected elements of the parent view are also selected (screenshot Pic1), code below:

RobotStructure struc = rbApp.Project.Structure;
RobotSelection rselection = struc.Selections.Get(IRobotObjectType.I_OT_OBJECT);

rselection.FromText(dicStories[item]);
IRobotView3 viewRobot = (IRobotView3)rbApp.Project.ViewMngr.CreateView(IRobotViewType.I_VT_STANDARD);
viewRobot.Selection.Set(IRobotObjectType.I_OT_OBJECT, rselection);
viewRobot.Visible = 1;
viewRobot.Redraw(0);
viewRobot.Projection = IRobotViewProjection.I_VP_XY;

Can you help me? 

Thanks for your help.

Pic 1Pic 1

0 Likes
Reply
Accepted solutions (1)
415 Views
3 Replies
Replies (3)

chjpcoi
Advocate
Advocate

Hi @Rafal.Gaweda 

Can you help me? please!

0 Likes

Stephane.kapetanovic
Advisor
Advisor
Accepted solution

hi @chjpcoi 

Public ViewMngr As IRobotViewMngr

Sub create_view_from_selection()
    Dim Robapp As IRobotApplication
    Set Robapp = New RobotApplication
    
    Set ViewMngr = Robapp.Project.ViewMngr
    
    Dim ActiveView As RobotView
    Set ActiveView = ViewMngr.GetView(ActiveViewNumber)
    
    Dim CurrentType As IRobotViewType
    CurrentType = ActiveView.Type
    
    Dim View As IRobotView3
    Set View = ViewMngr.CreateView(CurrentType)
        View.Projection = ActiveView.Projection
        ' Possible to Add more parameters as view setting or display
    
    Dim RSel As RobotSelection
    Dim TypeSel As IRobotObjectType
    Tb_Type = Array(IRobotObjectType.I_OT_NODE, _
                    IRobotObjectType.I_OT_BAR, _
                    IRobotObjectType.I_OT_GEOMETRY, _
                    IRobotObjectType.I_OT_OBJECT, _
                    IRobotObjectType.I_OT_PANEL, _
                    IRobotObjectType.I_OT_FINITE_ELEMENT)
    ' Possible to limit or Add more selection type
    
    For i = LBound(Tb_Type) To UBound(Tb_Type)
      TypeSel = Tb_Type(i)
      Set RSel = Robapp.Project.Structure.Selections.Get(TypeSel)
      View.Selection.Set TypeSel, RSel
    Next i
    
    View.Visible = True
    View.Redraw (0)
    Robapp.Project.ViewMngr.Refresh
    View.Window.Activate

    Set Robapp = Nothing
End Sub

Function ActiveViewNumber()
   For i = 1 To ViewMngr.ViewCount
     If ViewMngr.GetView(i).Window.IsActive <> 0 Then
       ActiveViewNumber = i: Exit Function
     End If
   Next i
End Function

See also

https://forums.autodesk.com/t5/robot-structural-analysis-forum/view-with-isolated-elements-via-ros-a...

 

 

chjpcoi
Advocate
Advocate

Hi @Stephane.kapetanovic 

Thank for your help. 

 
0 Likes