Code to duplicate a part with its plan by a macro in solidworks

Hello, I would like to duplicate a part A with its plane A into a part B and therefore a plan B by a macro in solidworks 2013.

I can't find how to transcribe the "Save copy as" manipulation into code to make the macro.

 

Could you help me?

 

Thank you

Guillaume

Hello, I don't know much about maccro though, I found a forum topic where someone created a maccro for a take-home composition and he has some code problems, like you, his problem has been solved. If it can help you?

http://www.forum-cao-3d.fr/api-questions/macro-de-composition-a-emporter-t11454.html

Hello

 

Sub main()

Set swApp = _
Application.SldWorks

Set Part = swApp.ActiveDoc
longstatus = Part.SaveAs3("C:\path....\part name", 0, 0)
End Sub

Try this?

 

Thank you but it doesn't solve my pb.

The copy works well for the piece and the plan. Basically, I can copy part A and plan A into room B and a plan B, but room B points to plan B but plan B points to room A.

How do I get Plan B to point to Exhibit B?

When doing the manipulation with Solidworks in "manual", I use  "Save copy as" but what is the code for this manipulation? Part.saveas(path, ????,????,????, etc)

 

 

On MyCadBlog I found a solution but does anyone have this macro?

 

http://www.mycadblog.fr/comment-dupliquer-une-piece-avec-sa-mise-en-plan-associee/

 

Hello, did you try to look at the link I posted above? Because what you're trying to do is a take-home composition and that's the macro they make on the forum topic I posted.

Hello

I created one that I made available on Lynkoa here:

http://www.lynkoa.com/tutos/3d/macro-enregistrer-sous-avec-solidworks

 

All code is commented out for clarity.

Great, thank you I managed to make it work by keeping the new link thank you to you

Hello

SmartProperties allows naming the files and when the property that create the name changes, this will create a new room with the new name and also copy the drawing.

Philippe