0

How can I use a VBA macro in the 3DExperience to save a part as a step file? I have found references in the documentation to the ExportData method, which requires it to be referred to a document, but I cannot figure out how to get the current active document. In an example I found online for CATIA V5 they use the "Open" method to convert files, but I would like to refer to the current active document instead, how could I do this?

Thanks!!!

Dim PartDocument0 As Document
' Reading a CATPart file
Set PartDocument0 = CATIA.Documents.Open("C:\desktop\File1.CATPart")
' Saving the part in a STEP file
PartDocument0.ExportData("C:\desktop\File1.stp", "stp")

Documentation references:

Exportdata

Sub ExportData(fileName As String, format As String)

Member of INFITF.Document

ActiveDocument

Property ActiveDocument As Document

Member of INFITF.CATIAApplicationCoClass read-only

Document

Sub ExportData(fileName As String, format As String)

Member of INFITF.Document

Application

Property Application As CATIAApplicationCoClass

read-only

Member of INFITF.AnyObject

But if I run the following code:

Dim PartDocument1 As Application
Set PartDocument1 = CATIA.ActiveDocument

or even the following code:

Dim PartDocument1 As Documents
Set PartDocument1 = CATIA.ActiveDocument

I get the error:

Method "ActiveDocument" of object "Application" failed

drypatrick
  • 437
  • 1
  • 4
  • 17
  • Please have a look on the `ActiveDocument` of the application object (e.g. _Set oPartDoc = CATIA.ActiveDocument_) – Shrotter Apr 11 '23 at 13:11
  • Unfortunately the CATIA object has no ActiveDocument properties or method – drypatrick Apr 13 '23 at 08:35
  • Have you checked the documentation? (I guess instead of _ActiveDocument_ there is a _ActiveEditor_ Object) – Shrotter Apr 13 '23 at 17:26
  • I've added some references to the documentation, ExportData is a method of Document object, so I can't une it on the Editor – drypatrick Apr 15 '23 at 11:41

1 Answers1

1

Unfortunately, I don't think there is an equivalent of the ExportData function with 3DExperience. Only thing I have found close to a solution is using StartCommand and SendKeys functions to simulate key presses: https://www.coe.org/p/fo/et/thread=28059

yet it is not a robust solution, tho it may solve your problem. I would really appreciate it if you came up with a solution and share it.

MCD52
  • 51
  • 3