(API) Command VBA Projection Capture of a view

(API) Command VBA Projection Capture of a view

Anonymous
Not applicable
47,316 Views
146 Replies
Message 1 of 147

(API) Command VBA Projection Capture of a view

Anonymous
Not applicable

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.

0 Likes
Accepted solutions (1)
47,317 Views
146 Replies
Replies (146)
Message 141 of 147

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @Anonymous

 

See post 137.

 



Rafal Gaweda
0 Likes
Message 142 of 147

Anonymous
Not applicable

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?

 

0 Likes
Message 143 of 147

Anonymous
Not applicable

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!

 

 

0 Likes
Message 144 of 147

Rafal.Gaweda
Autodesk Support
Autodesk Support
Message 145 of 147

Anonymous
Not applicable

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

0 Likes
Message 146 of 147

Stephane.kapetanovic
Mentor
Mentor

hi @Anonymous 

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

 

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 147 of 147

mohamed_bareche
Explorer
Explorer

Salut @Rafal.Gaweda 

Est-ce que c'est possible avec l'API de capturer les valeurs min/max en couleur rouge et vert sur un diagramme avec un code ?

0 Likes