API ROBOT Screen capture - black views

API ROBOT Screen capture - black views

polylouis
Enthusiast Enthusiast
1,864 Views
6 Replies
Message 1 of 7

API ROBOT Screen capture - black views

polylouis
Enthusiast
Enthusiast

Hi everyone,

 

I have one question about screen capture. 

If I create .rtf file with captures all is good but if I save screen capture from clipboard the view is black :

 

modele_view=structure.Selections.Get(IRobotObjectType.I_OT_OBJECT)
modele_view.FromText("Panel")
viewRobot=IRobotView3(app.Project.ViewMngr.CreateView(IRobotViewType.I_VT_STANDARD))
viewRobot.Selection.Set(IRobotObjectType.I_OT_OBJECT, modele_view)
viewRobot.Visible = True
viewRobot.Redraw(0)
viewRobot.Projection=IRobotViewProjection.I_VP_3DXYZ
viewRobot.Title = "Vue du modèle"
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_STRUCTURE_STRUCTURE, True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_STRUCTURE_BAR_NUMBERS, True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_STRUCTURE_SUPPORT_SYMBOLS, True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_STRUCTURE_ATTRIBUTE_LABELS, True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_SECTIONS_NAME, True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_SECTIONS_SURFACE, True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_SECTIONS_MATERIAL, True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_FE_PANEL_CONTOURS, True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_FE_PANEL_NAMES , True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_FE_PANEL_THICKNESSES  , True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_FE_CONTOUR_COMPONENTS, True)
viewRobot.ParamsDisplay.Set(IRobotViewDisplayAttributes.I_VDA_ADVANCED_ELASTIC_FOUNDATION, True)
scPar=IRobotViewScreenCaptureParams(app.CmpntFactory.Create(IRobotComponentType.I_CT_VIEW_SCREEN_CAPTURE_PARAMS))
scPar.Name="Vue du modèle"
scPar.UpdateType = IRobotViewScreenCaptureUpdateType.I_SCUT_CURRENT_VIEW
scPar.Resolution = IRobotViewScreenCaptureResolution.I_VSCR_4096
scPar.UpdateType = IRobotViewScreenCaptureUpdateType.I_SCUT_COPY_TO_CLIPBOARD
viewRobot.MakeScreenCapture(scPar)

from PIL import ImageGrab, Image
im= ImageGrab.grabclipboard()
if isinstance(im, Image.Image):
    im.save('Vue du modèle.png')
 
Do you have any ideas to fix it ?
 
Thank you in advance,
Regards 
 
Louis 
0 Likes
Accepted solutions (1)
1,865 Views
6 Replies
Replies (6)
Message 2 of 7

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @polylouis 

 

Have you tried :
put a delay between copying and saving,
save in another format (bmp),
refresh the view before capture (viewmngr.refresh),
to decrease the resolution (2048, 3072),
to review whether the structure is actually visible before capture

To set on and off parameters

 

Best regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
Message 3 of 7

Stephane.kapetanovic
Mentor
Mentor

it is also possible to save your captures directly in Excel or Word rather than saving it to disk.

#146

https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-command-vba-projection-capture-of...

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
0 Likes
Message 4 of 7

polylouis
Enthusiast
Enthusiast

Thnak you Stephan ! 

 

Antoher question: I would like to know if it is possible to see extreme values on panel like following picture :  

capture.JPG

 

I ddi not find the api command to add on my code.

 

Thank you in advance,

Louis 

0 Likes
Message 5 of 7

jhe55NCY
Enthusiast
Enthusiast

Hi again @Stephane.kapetanovic,

I have a similar issue when I am using the API for screen capture. I have found the line of my code which seems to be causing the blackout issue. The line is:

'viewRobot.SetSize width, height'

jhe55NCY_2-1668007825005.png

If I don't comment this line out, it causes my Robot window to disappear and the image to be completely black (apart from the coordinate system)

jhe55NCY_1-1668007755015.png

 

jhe55NCY_0-1668007558229.png

 

I would like my figures to be landscape so I would like to have the viewRobot.SetSize line of code in, or a suitable work around. Can you help me with this?

0 Likes
Message 6 of 7

Stephane.kapetanovic
Mentor
Mentor

hi @jhe55NCY 

the setsize function defines the size of the window box. With such dimensions (370x300mm) it must be larger than your screen. You could test the GetSize function which will return its current size.
The idea of adjusting the size of the window and not the zoom is to fit taller than wide structures or to have the legend closer to the structure.
The rest of the adjustment must be done with SetZoom.
The black screen may appear on the capture if the refresh time is not sufficient between the time the view is configured and the time the shot is taken.
It is possible depending on how you have set up the view that the structure does not appear. I recommend that you read the following topic to adjust your eyesight.

https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-command-vba-projection-capture-of...

After that you can communicate your code. </>

Best regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
Message 7 of 7

jhe55NCY
Enthusiast
Enthusiast

Hi @Stephane.kapetanovic,

Thank you for your suggestions. The code didn't actually require any updating to it, I found that the black screen would occur when I was using a second monitor, but work fine when just using one screen. Through trial and error, I determined that to prevent a black screen, I needed to have the Robot window open and maximised on my primary screen (number 1 screen on display detect). Even though my second monitor is larger than my primary screen, I would still get a black image if I did not follow this guidance. 

Hopefully, this may help other people who experience this frustrating issue.

Best wishes,

James