×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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 --> VBA

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

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

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

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

(OP)
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

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

(OP)
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 --> VB

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!

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

(OP)
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 --> VBA

Sub SaveAsSTL(Name)
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
End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources