Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save 3DPart as .stl file in CATIA v6 (Please help me)

Status
Not open for further replies.

jproberge

Mechanical
May 2, 2014
10
CA
Hello everyone,

I've been spending days trying to solve this issue. I'm trying to write a VBA script that can export a 3D part to a STL file in V6, and I'm not able to find a solution. In V5, you could use something like:

Code:
Dim myDoc as PartDocument
Set myDoc = CATIA.ActiveDocument
myDoc.exportData "Filename.stl", "stl"

But it CATIA v6, this is no longer valid (!). Does anyone of you know how to adapt the code above so it could work in V6?

Any hint is really appreciated!

Thanks
 
Replies continue below

Recommended for you

From on line docs, I see is related to Sections but maybe is working also for what you want (I don't have v6)

Methods


o Sub Export( Part ioPart)

Exports the sections curves of the section in a 3DShape representation this method assumes that you have created the Part in which you want to do the export
Returns:
The 3DShape Representation
Example:
Dim MyOpenEditor As Editor
Set myNewService = CATIA.GetSessionService("PLMNewService")
myNewService.PLMCreate "3DShape", myOpenEditor
Dim myPart As Part
Set myPart = CATIA.ActiveEditor.ActiveObject
mySection.Export myPart

o Sub ExportTo( CATBSTR iFormat,
CATBSTR iSavePath)

Exports the section into dxf/dwg formats. It takes inputs as type to which you want to export as "dxf" or "dwg" and path where you want to save exported file(without extension).
Example:
mySection.ExportTo "dxf", "c:\ExportDxf" (For export as dxf)
mySection.ExportTo "dwg", "c:\ExportDwg" (For export as dwg)



Regards
Fernando

 
Hi!

Thank you Ferdo for your reply, it's very much appreciated!

Unfortunately, I had already checked the export(Part ioPart) method and it doesn't allow a user to export a 3Dpart as a STL file. This latter method is made for the 2D exports of a section in a 3d part...

So, I guess we are back to square one :( ... Does anyone knows how to automate (with vb) the export of 3dparts as stl in CATIA v6?

Thanks

 
Hi!

Ok, I'm sorry to bump my question on top, but I really need to find a solution on this one...

To me it's surprising that finding a solution to this problem is not straightforward, as I think it might be very likely for someone to look to automate the process of exporting part files. Anyway, so far, one method that seems promising is to use the "StartCommand" method like:

Code:
CATIA.StartCommand ("Export")

But I'm stuck there, not knowing how to automatically name the part and choose "stl" as the format.

Does anyone has an idea?

Thanks a lot!
 
Hi!

Thanks again Ferdo for your reply.

For those who are wondering, I finally succeeded to write a VBA script to automate the export as STL file process. My code is very far from being efficient or beautifully designed, it's messy, I won't say I'm proud of it, but it works perfectly fine and without any failure(s)! I thought it might be relevant to share it to others so I pasted it below. Before running it, you must have your product or part already opened in the editor. So here it is:



Code:
Sub SaveAsSTL(Name)
[indent]CATIA.StartCommand ("Export")
AppActivate "CATIA V6"  'Make sure CATIA V6 Windows is activated
CATIA.RefreshDisplay = False 'Do not refresh screen for the following lines
Sleep 2000 'Let the export command process
Dim PartName As String
Dim EnterKey As String
Dim TabKey As String
Dim DownKey As String
PartName = Name 
EnterKey = "{ENTER}"
TabKey = "{TAB}"
DownKey = "{DOWN}"
SendKeys PartName, True 'Write the Filename in the export window prompt
DoEvents
SendKeys TabKey, True 'Switch the control to the file type field 
DoEvents
SendKeys DownKey, True 'Hit down key three times to reach "stl"
DoEvents
SendKeys DownKey, True
DoEvents
SendKeys DownKey, True
DoEvents
SendKeys EnterKey, True 'Press Enter one time to confirm "stl" as file type
DoEvents
SendKeys EnterKey, True 'Press Enter several other time to launch the process
DoEvents
SendKeys EnterKey, True
DoEvents
SendKeys EnterKey, True
DoEvents
Sleep 2000 ' Let the export process do its job and press Enter after to close the success messages
DoEvents
SendKeys EnterKey, True
DoEvents
SendKeys EnterKey, True
DoEvents
SendKeys EnterKey, True
DoEvents[/indent]
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top