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
8531 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 141 of 146
Rafal.Gaweda
in reply to: rhlkochar

Hi @rhlkochar

 

See post 137.

 



Rafal Gaweda
Message 142 of 146
rhlkochar
in reply to: Rafal.Gaweda

Hi @Rafal.Gaweda,

 

I did the same. I copied the screen capture on to the clipboard and tried to paste it in Excel. It doesn't work. The screen capture is in what format? I am unable to get that. 

 

if (Clipboard.GetDataObject() != null)
{
IDataObject data = Clipboard.GetDataObject();

if (data.GetDataPresent(DataFormats.Bitmap))
{
Image image = (Image)data.GetData(DataFormats.Bitmap, true);

image.Save("image.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
image.Save("image.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
image.Save("image.gif", System.Drawing.Imaging.ImageFormat.Gif);
}
else
{
MessageBox.Show("The Data In Clipboard is not as image format");
}
}
else
{
MessageBox.Show("The Clipboard was empty");
}

 

When I try the above snippet of code, it shows that the data in clipboard is not in image format.

 

I am trying to paste the contents of clipboard like this:

xlWorkbook.Sheets["Results"].Range("B" + D * 45).Paste();

 

But this doesn't work. It throws an error. I somehow feel it is due to the format of the clipboard contents.

 

I have been able to do it in VBA though.

Call InsPicFromClipbrd("B" & M * 45, TitleName)

 

This works great. 

 

Could you please help me resolve this for my C# code?

 

Message 143 of 146
rhlkochar
in reply to: rhlkochar

Hi @Rafal.Gaweda,

 

I also tried to save the screenshot as a.rtf file as follows:

 

RobotMapView.MakeScreenCapture(SSParams);
string fichier_sortie = "C:\\Users\\KOCH2401\\OneDrive Corp\\OneDrive - Atkins Ltd\\Desktop\\outjpg.rtf";
robotApplication.Project.PrintEngine.SaveReportToFile (fichier_sortie,IRobotOutputFileFormat.I_OFF_RTF_JPEG);

 

 

This does create the .rtf but it is blank. No screenshot. Just some text. Could you also please tell me why this is happening? 

 

Thanks!

 

 

Message 144 of 146
Rafal.Gaweda
in reply to: rhlkochar
Message 145 of 146

Hi,

It may not be a robot API topic directly but, how can I paste image from clipboard in a word file?

Thks in advance

Message 146 of 146

hi @ClémentTAHERI6316 

You can find a code in VBA below. Take care to regularly inspect the clipboard.

Sub Copy_RobotCapture_To_WordDocument()
  ' Word
  Dim wordApp As Word.Application
  Dim wdDoc As Word.Document
  Dim paragraph As Word.paragraph

  Set wordApp = CreateObject("Word.Application")
  Set wdDoc = wordApp.Documents.Add
  
  ' Autodesk Robot Structural Analysis
  Dim RobApp As IRobotApplication
  Dim ViewMngr As IRobotViewMngr
  Dim ExportView As RobotView
  Dim ScPar As RobotViewScreenCaptureParams

  Set RobApp = New RobotApplication
  If RobApp.Visible = False Then
    Set RobApp = Nothing: Exit Sub
  End If
  
  Set ViewMngr = RobApp.Project.ViewMngr
  For i = 1 To ViewMngr.ViewCount
    If ViewMngr.GetView(i).Window.IsActive <> 0 Then
      ActiveViewNumber = i: Exit For
    End If
  Next i
  Set ExportView = ViewMngr.GetView(ActiveViewNumber)
  ' -------------
  ' Do something
  ' -------------
  Set ScPar = RobApp.CmpntFactory.Create(I_CT_VIEW_SCREEN_CAPTURE_PARAMS)
  ScPar.UpdateType = I_SCUT_COPY_TO_CLIPBOARD
  ScPar.Resolution = I_VSCR_2048
  ExportView.MakeScreenCapture ScPar
  
  Set paragraph = wdDoc.Content.Paragraphs.Add
  paragraph.Range.Text = " "
  paragraph.Range.Paste
  paragraph.Range.InsertParagraphAfter
    
  wordApp.Visible = True
  Set wdDoc = Nothing: Set wordApp = Nothing
  Set RobApp = Nothing
End Sub

Best regards

 

Tags (3)

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

Post to forums  

Autodesk Design & Make Report