Robot Structural Analysis Forum
Welcome to Autodesk’s Robot Structural Analysis Forums. Share your knowledge, ask questions, and explore popular Robot Structural Analysis topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

(API) Command VBA Projection Capture of a view

145 REPLIES 145
SOLVED
Reply
Message 1 of 146
mateaus
8165 Views, 145 Replies

(API) Command VBA Projection Capture of a view

Hi,

 

I have a problem with my macro. The command of projection in 3D doesn't work. My view stay in XZ plane.

 

robapp.Window.Activate
Set mavueRobot = robapp.Project.ViewMngr.CreateView(1)
mavueRobot.Projection = I_VP_3DXYZ


mavueRobot.Visible = True
mavueRobot.Redraw (True)

 

I want also make a capture of my model with diagram of results. Have you an example of code for it ?

 

I would like to get for final result the exemple in attachment.

145 REPLIES 145
Message 81 of 146
mateaus
in reply to: Rafal.Gaweda

Ok but my PC is new and I don't have installed any Robot before. I have only installed RSA 2012.

Message 82 of 146
Rafal.Gaweda
in reply to: mateaus

To register it properly please open Command Prompt as Administrator, registsrer robot, check macro.

 

If it still does not work please respond to e-mail sent to yout from our system



Rafal Gaweda
Message 83 of 146
mateaus
in reply to: sorgjee


@sorgjee wrote:

Your EXACT code does not run due to a typo. Even without the typo, and using the rest of the code exactly as you've written, yes, it still crashes.error again.PNG

 

 

 

Regards,

Even


It's the same for me. Robot crash when ask for better resolution.

 

captures high resolution.PNG

 

I think it's because my computer is not enough speed. When I do some break in the macro it's working. What do I need in the computer ? 

 

I'm in windows seven 64bit with ARSA 2012 and Office 2010

Message 84 of 146
Rafal.Gaweda
in reply to: mateaus

Use from time to time DoEvents

or pause code in some places. Pause function dos not exist in VBA so write your own function - example below

This function pauses code for 5 seconds

 

Sub Wait()
    waitTime = 5
    Start = Timer
    While Timer < Start + waitTime
        DoEvents
    Wend
End Sub

 



Rafal Gaweda
Message 85 of 146
mateaus
in reply to: Rafal.Gaweda

Is that possible to ask Robot : "W


@rg_Adsk wrote:

Use from time to time DoEvents

or pause code in some places. Pause function dos not exist in VBA so write your own function - example below

This function pauses code for 5 seconds

 

Sub Wait()
    waitTime = 5
    Start = Timer
    While Timer < Start + waitTime
        DoEvents
    Wend
End Sub

 



hen the generation of the vue is finished, do something else" ?

Message 86 of 146
Rafal.Gaweda
in reply to: mateaus

View generation is one command \ line. After finishing it program steps to another code line. 



Rafal Gaweda
Message 87 of 146
mateaus
in reply to: Rafal.Gaweda


@rg_Adsk wrote:

View generation is one command \ line. After finishing it program steps to another code line. 


So how explain that robot crash if I don't put sleeping times :

 

Sleep 33000  '33 secondes to generate a view of mobile loads

 

Sub cree_vues_resultats()

If Not Robapp.Visible Then
    Set Robapp = Nothing
    MsgBox "Open Robot", vbOKOnly, "ERROR"
    Exit Sub
End If

fichier_sortie = Range("AE16").Value

Dim mavueRobot As IRobotView3 ' this is important to set IRobotView3 if you want to make screen capture of this view

Set mavueRobot = Robapp.Project.ViewMngr.GetView(1) ' it seems CreateView makes this strange affect, use GetView instead

mavueRobot.ParamsDisplay.Set 68, False                               'symbole charges ponctuelles
mavueRobot.ParamsDisplay.Set 69, False                               'symbole charges lineaires
mavueRobot.ParamsDisplay.Set 70, False                               'symbole charges surfaciques

mavueRobot.Projection = I_VP_XY_3D
'mavueRobot.Projection = I_VP_3DXYZ
mavueRobot.ParamsDisplay.Set I_VDA_OTHER_RULER, True
Robapp.Project.ViewMngr.Refresh

'faire un zoom
Sheets("Sommaire").Select
transvfactor = Range("I32").Value
transhfactor = Range("I31").Value
zoomfactor = Range("I30").Value

Call zoom_robot

'mavueRobot.Visible = True
'mavueRobot.Redraw (True)
'Robapp.Project.ViewMngr.Refresh

'MsgBox ("Regler la vue dans le modèle")

Sheets("Sommaire").Select
casprem = Range("N18").Value
casder = Range("N19").Value
prem_cas_roul = Range("N17").Value + 1

For i = casprem To casder
Cas = i

mavueRobot.ParamsFeMap.WithDescription = True
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_SYMBOLS, False

If Range("I21").Value = "Myy +" Then
mavueRobot.ParamsFeMap.CurrentResult = I_VFMRT_COMPLEX_REINFORCE_TOP_MYY
sollicitation = "Moments Myy+"
'pour les charges roulantes attention
If i >= prem_cas_roul Then
Cas = prem_cas_roul + (casder - prem_cas_roul + 1) * 3 + ((i - prem_cas_roul) * 2 + 0)
End If
End If

If Range("I21").Value = "Mxx +" Then
mavueRobot.ParamsFeMap.CurrentResult = I_VFMRT_COMPLEX_REINFORCE_TOP_MXX
sollicitation = "Moments Mxx+"
'pour les charges roulantes attention
If i >= prem_cas_roul Then
Cas = prem_cas_roul + (casder - prem_cas_roul + 1) * 3 + ((i - prem_cas_roul) * 2 + 0)
End If
End If

If Range("I21").Value = "Myy -" Then
mavueRobot.ParamsFeMap.CurrentResult = I_VFMRT_COMPLEX_REINFORCE_BOTTOM_MYY
sollicitation = "Moments Myy-"
'pour les charges roulantes attention
If i >= prem_cas_roul Then
Cas = prem_cas_roul + (casder - prem_cas_roul + 1) * 3 + ((i - prem_cas_roul) * 2 + 1)
End If
End If


If Range("I21").Value = "Mxx -" Then
mavueRobot.ParamsFeMap.CurrentResult = I_VFMRT_COMPLEX_REINFORCE_BOTTOM_MXX
sollicitation = "Moments Mxx-"
'pour les charges roulantes attention
If i >= prem_cas_roul Then
Cas = prem_cas_roul + (casder - prem_cas_roul + 1) * 3 + ((i - prem_cas_roul) * 2 + 1)
End If
End If

mavueRobot.Selection.Get(I_OT_CASE).FromText (Cas) ' selecting case for results display

ecran_capture = sollicitation & "_ Cas " & i

mavueRobot.Redraw (0)
Sleep 33000  '33 secondes to generate a view of mobile loads
Robapp.Project.ViewMngr.Refresh



Call screen_capture


Next i

 'saving printout \ report to file
'robapp.Project.PrintEngine.SaveReportToFile fichier_sortie, I_OFF_RTF_JPEG
Robapp.Project.PrintEngine.SaveReportToFile fichier_sortie, I_OFF_RTF
'or directly opening printout in Word
Robapp.Project.PrintEngine.ExternalPreviewReport EPF_MS_OFFICE

'MsgBox "QUITTER APPLICATION ROBOT"
Sleep 10000

Robapp.Quit I_QO_DISCARD_CHANGES  ' Quitter sans sauvegarde

End Sub

 

Message 88 of 146
Rafal.Gaweda
in reply to: mateaus

send me whole your xls file and any other files required like mobile loads database etc.



Rafal Gaweda
Message 89 of 146
mateaus
in reply to: Rafal.Gaweda

Hi

 

I've got a problem with the scale in the view. It's not the good one I have to do the command normalize in Robot.

 

normaliser echelle.PNG

 

Is there a command in VBA API for this ?

Message 90 of 146
Rafal.Gaweda
in reply to: mateaus

Unfortunately you can not control scale on force normalization thru API.



Rafal Gaweda
Message 91 of 146
mateaus
in reply to: Rafal.Gaweda

Hi,

 

I would like to select all "combinaisons" or all of "cas simples" but not both.

 

combinaisons selection.PNG

 

I test 

 

mavueRobot.Selection.Get(I_OT_CASE).FromText ("Combinaisons") ' selecting case for results display

 

but it doesn't work,

 

Have you got a solution ?

 

 

 

 

Message 92 of 146
Rafal.Gaweda
in reply to: mateaus

Dim SimpleCaseSel As RobotSelection
Dim ManualCombSel As RobotSelection

Set SimpleCaseSel = RobApp.Project.Structure.Selections.CreatePredefined(I_PS_CASE_SIMPLE_CASES)
Set ManualCombSel = RobApp.Project.Structure.Selections.CreatePredefined(I_PS_CASE_COMBINATIONS)


mavueRobot.Selection.Get(I_OT_CASE).FromText (SimpleCaseSel.ToText) ' all simple case for results display

'or

mavueRobot.Selection.Get(I_OT_CASE).FromText (ManualCombSel.ToText) ' all manual combinations for results display

 



Rafal Gaweda
Message 93 of 146
mateaus
in reply to: Rafal.Gaweda

I would like to add a fiew pages in my note like the attached file by macros VBA.

 

caracteristics

+nodes

+bars

+loads

+...

+ Captures of views

 

Is that possible ?captures&donnéesmodele.PNG

Message 94 of 146
Rafal.Gaweda
in reply to: mateaus


mateaus wrote:

I would like to add a fiew pages in my note like the attached file by macros VBA.

 

caracteristics

+nodes

+bars

+loads

+...

+ Captures of views

 

Is that possible ?


I guess you want to make screen captures of tables.

Create table, make screen capture of it, Example code below:

 

Dim Rtable As RobotTable
Dim ScPar As RobotTableScreenCaptureParams
Set ScPar = robapp.CmpntFactory.Create(I_CT_TABLE_SCREEN_CAPTURE_PARAMS)

ScPar.Name = "Rtable"

Set Rtable = robapp.Project.ViewMngr.CreateTable(I_TT_BARS, I_TDT_BAR)
'  Rtable.AddColumn 1  -  modify tables if you want by adding or removing columns
Rtable.MakeScreenCapture ScPar

 



Rafal Gaweda
Message 95 of 146
Rafal.Gaweda
in reply to: mateaus


I've got a problem to export result view in a file (word or rtf)

 and the header with word are not good :

 Can you help me ?


If it is not sorted out by you please send me your macro.



Rafal Gaweda
Message 96 of 146
mateaus
in reply to: Rafal.Gaweda

Hi,

 

My command 

 

Robapp.Quit I_QO_DISCARD_CHANGES

 

doesn't work any more.

 

Do you have a solution. I just want to save and quit the model.

Message 97 of 146
Rafal.Gaweda
in reply to: mateaus


I just want to save and quit the model.


robapp.Quit I_QO_SAVE_CHANGES



Rafal Gaweda
Message 98 of 146
mateaus
in reply to: Rafal.Gaweda

that's the same Robot can't close normally. The programm bug :

 

bug robot.PNG

Message 99 of 146
Rafal.Gaweda
in reply to: mateaus

Send me the latest version of your macro.



Rafal Gaweda
Message 100 of 146
mateaus
in reply to: Rafal.Gaweda

Sub robot_donnees()

' ouverture de robot, la session s'appellera robapp
Set Robapp = New RobotApplication

' ce sera une structure de type panneaux
Robapp.Project.New (I_PT_SHELL)
    
If Range("I24").Value = "NON" Then
Robapp.Visible = False
Else
Robapp.Visible = True
End If

If Range("I25").Value = "NON" Then
Robapp.Interactive = False
Else
Robapp.Interactive = True
End If

If Range("I26").Value = "NON" Then
Robapp.UserControl = False
Else
Robapp.UserControl = True
End If

Dim RetVal

Sleep 1000

A = Range("AE2").Value

affaire = Range("AE14").Value


Robapp.Project.OpenExtFile A, I_EFF_STR, 1  ' Ouvre le fichier text se trouvant dans A

Call initialisation_semelle
 
Call Plaque_Robot

' MsgBox "Calcul terminé"


'robapp.Project.Close

'robapp.Quit = True

'Appuis entretoises


'Call appuis_robot

Call charges


Robapp.Project.CalcEngine.Calculate ' calculate model


Dim mavueRobot As IRobotView3 ' this is important to set IRobotView3 if you want to make screen capture of this view
Set mavueRobot = Robapp.Project.ViewMngr.GetView(1)


'Vue mise à jour
mavueRobot.Projection = I_VP_3DXYZ
mavueRobot.Redraw (True)
mavueRobot.ParamsDisplay.SymbolSize = 2 'marche uniquement avec ROBOT 2012
Robapp.Project.ViewMngr.Refresh

'sauvegarde fichier robot
sauv = affaire

Robapp.Project.SaveToFormat I_PSF_RTD, sauv
'robapp.Project.SaveAs sauv

Sheets("Sommaire").Select

MsgBox "QUITTER APPLICATION ROBOT"

Robapp.Quit I_QO_DISCARD_CHANGES  ' Quitter sans sauvegarde

End Sub

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report