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
8157 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 61 of 146
sorgjee
in reply to: Rafal.Gaweda

Hi Rafal,

 

Using the below command with Robot 12 and Excel 2007 causes excel to crash. Is this a known issue?

    ScPar.Resolution = I_VSCR_4096

 

Regards,

Even

Message 62 of 146
Rafal.Gaweda
in reply to: sorgjee

 

Using the below command with Robot 12 and Excel 2007 causes excel to crash. Is this a known issue?

    ScPar.Resolution = I_VSCR_4096

 

It should work.

 

Public robapp As RobotApplication

 

Private Sub CommandButton1_Click()

 

Set robapp = New RobotApplication

 

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

Set viewRobot = robapp.Project.ViewMngr.GetView(1)

 

viewRobot.Projection = I_VP_3DXYZ

viewRobot.Redraw (True)

robapp.Project.ViewMngr.Refresh

 

Call screen_capture


End Sub


Sub screen_capture()

 

Dim viewRobot As IRobotView3
Set viewRobot = robapp.Project.ViewMngr.GetView(1)
Dim ScPar As RobotViewScreenCaptureParams
Set ScPar = robapp.CmpntFactory.Create(I_CT_VIEW_SCREEN_CAPTURE_PARAMS)

 

ScPar.Name = "capture"
ScPar.UpdateType = I_SCUT_CURRENT_VIEW
ScPar.Resolution = I_VSCR_4096
viewRobot.MakeScreenCapture ScPar
robapp.Project.PrintEngine.AddScToReport "capture"

 

End Sub

 

 


Try this (last post in this thread):

 

http://forums.autodesk.com/t5/Autodesk-Robot-Structural/VBA-Excel-macro-for-any-object-geometry-modi...




Rafal Gaweda
Message 63 of 146
sorgjee
in reply to: Rafal.Gaweda

Hi Rafal,

 

The macro you provided runs, but as soon as it comes to the Resolution command it causes excel to crash.

 

excel error.PNG

Message 64 of 146
Rafal.Gaweda
in reply to: sorgjee

Have you tried this ?:

 

 

Try this (last post in this thread):

 

http://forums.autodesk.com/t5/Autodesk-Robot-Structural/VBA-Excel-macro-for-any-object-geometry-modi...





Rafal Gaweda
Message 65 of 146
sorgjee
in reply to: Rafal.Gaweda

Yes, makes no difference. Still crashing the exact same way.

 

Regards,

Even

Message 66 of 146
Rafal.Gaweda
in reply to: sorgjee

What happens if you use diffeent screen capture resolution ?

 

ScPar.Resolution = I_VSCR_2048

 

or


ScPar.Resolution = I_VSCR_3072

 

 



Rafal Gaweda
Message 67 of 146
sorgjee
in reply to: Rafal.Gaweda

Same crash for excel.

Message 68 of 146
Rafal.Gaweda
in reply to: Rafal.Gaweda

What is sisplayed after running this macro in Excell cells:

 

Private Sub Ver()

 

Dim robapp As RobotApplication

Set robapp = New RobotApplication

 

Cells(1, 1) = robapp.Version
Cells(2, 1) = robapp.ProgramVersion

 

End Sub



Rafal Gaweda
Message 69 of 146
sorgjee
in reply to: Rafal.Gaweda

It comes out as:

12
25.0.3.3833
Message 70 of 146
Rafal.Gaweda
in reply to: sorgjee

Please try my EXACT code - published a few posts earlier.

Do not modify it.

I can see in your screen capture that in your screen_capture sub you create again robapp (which is already created by main function in my code)



Rafal Gaweda
Message 71 of 146
sorgjee
in reply to: Rafal.Gaweda

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

Message 72 of 146
Rafal.Gaweda
in reply to: sorgjee

Try this:

- open Macro and VB editor, go to references, uncheck Robot Object Modeler 12, save macro\ excell file, close excell, start excell, load the file, activate Robot Object Modeler 12 in references, run macro.

 

If it does not help try to create screen capture without setting resolution -> what effect?

 

One more: open robot, create such screen capture manually and report me the effect.



Rafal Gaweda
Message 73 of 146
sorgjee
in reply to: Rafal.Gaweda

  1. Tried this and still get same crash. I tried putting into a new spreadsheet, and still same.
  2. If I delete or comment out the resolution the screen capture works fine.
  3. Creating a large resolution screencapture 'manually' works fine.
Message 74 of 146
Rafal.Gaweda
in reply to: sorgjee

What happens if you use this code:

 

Sub screen_capture()

 

Dim mavueRobot As IRobotView3
Set mavueRobot = robapp.Project.ViewMngr.GetView(1)
Dim ScPar As RobotViewScreenCaptureParams
Set ScPar = robapp.CmpntFactory.Create(I_CT_VIEW_SCREEN_CAPTURE_PARAMS)

ScPar.Name = "capture"
ScPar.UpdateType = I_SCUT_COPY_TO_CLIPBOARD
mavueRobot.MakeScreenCapture ScPar
robapp.Project.PrintEngine.AddScToReport "capture"

 

End Sub

 

Still crash ?



Rafal Gaweda
Message 75 of 146
sorgjee
in reply to: Rafal.Gaweda

Hi Rafal,

 

This code does not crash.

 

The screen capture is not added to the report, but it is i nthe clipboard so can be pasted to a document or image edit programme.

 

Regards,

Even

Message 76 of 146
Rafal.Gaweda
in reply to: sorgjee

Do you use 32 or 64 bit Robot?

 

One test more. Please find in zttached zip the C# program which generates 4 screen captures. Please start robot, load any file, run this program, generate screen captures and report whether the error appears or not.



Rafal Gaweda
Message 77 of 146
sorgjee
in reply to: Rafal.Gaweda

I'm pretty sure it is 64 bit robot.

 

The programme runs fine, and produces 4 screen captures that look to be the correct resolution.

Message 78 of 146
Rafal.Gaweda
in reply to: sorgjee

I have not checked such configuration : Office 2007 32 bit and Robot 2012 64 bit. I will check it.

on my side Office 2007 32 bit and Robot 2012 32 bit.



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

Hi I have Robot 2012 64 bit with Excel 2010 and I can't run macro in my new computer. I did this :

 

- open Macro and VB editor, go to references, uncheck Robot Object Modeler 12, save macro\ excell file, close excell, start excell, load the file, activate Robot Object Modeler 12 in references, run macro.

 

but it doesn't work. Do I have to install something else ?

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

In such case unregister ALL ROBOTS you have installed on your computer by command: path_to_robot.exe / unregserver

 

eg:

"C:\Program Files\Autodesk\Autodesk Robot Structural Analysis Professional 2011\System\Exe\robot.EXE" /unRegServer

 

then 

 

register the one you want to use.

 

eg:

"C:\Program Files\Autodesk\Autodesk Robot Structural Analysis Professional 2012\System\Exe\robot.EXE" /RegServer



Rafal Gaweda

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

Post to forums  

Autodesk Design & Make Report