Reply

Solid edge macro for part Copy

[ Edited ]

 

Hi all,

If anybody knows, how i can write that program in VB, what do the followings please anwser

The problems is these:

I already do to open a new .par file (it was hard to me Smiley Happy), but i have to do something in it:

I want to insert a Part Copy without "Link to File" and after that, I want to save that opened document.

thanks

Mark

 

Posted by: kon mar
Post date: 7/2/2009 3:21:40 AM

9 REPLIES

RE: Solid edge macro for part Copy

[ Edited ]

Questions:

You want to insert a Part Copy in another file.

1. Is the new file empty or is there already a solid in it?

2. What language are you using (VB.Net, VB6, C++) ?

 

Posted by: Julian Guillo
Post date: 7/7/2009 7:51:39 AM

RE: Solid edge macro for part Copy

[ Edited ]

The new file is empty, and I want to insert that file, what I using, when I start the macro. (If it isnt workable, than we can open a browser to insert Part Copy...)

I'm using VB6.

 

Posted by: kon mar
Post date: 7/7/2009 10:21:38 AM

RE: Solid edge macro for part Copy

[ Edited ]

Try this small example. Paste the code in a button in a form:

 

Dim oSE As SolidEdgeFramework.Application

Dim oPar As SolidEdgePart.PartDocument

Dim FileName As String

 

Private Sub Command1_Click()

'Connect to Solid Edge.

Set oSE = GetObject(, "solidedge.application")

'Create a new document

Set oPar = oSE.Documents.Add("solidedge.partdocument")

'Insert part copy. This creates the Model object in the part file with a copied part in it.

FileName = "c:\test.par"

oPar.Models.AddCopiedPart FileName

'Break links.

oPar.Models(1).CopiedParts(1).BreakLinks

'Save new file

oPar.SaveAs "c:\newpart.par"

'Close

oPar.Close False

'Cleanup

Set oSE = Nothing

Set oPar = Nothing

End

End Sub

 

 

Posted by: Julian Guillo
Post date: 7/8/2009 12:16:33 AM

RE: Solid edge macro for part Copy

[ Edited ]

Thank you so much, it works, but in the declaration i have to do this way:

 

Dim oSE As Object

Dim oPar As Object

Dim FileName As String

 

I'd like to now where can I find all of codes for SE in VB6.

 

thanks again

 

Mark

 

Posted by: kon mar
Post date: 7/8/2009 7:45:13 AM

RE: Solid edge macro for part Copy

[ Edited ]

When you do a VB6 program for SE you can declare variables as "Object" but it's better to declare the exact type of object they are.

You can add the Reference libraries needed for Solid Edge in VB6 in:

Project --> References. Look into the list for "Solid Edge *" lines and check them all.

This will help you navigating the Solid Edge Application structure and allow you to declare objects as (for example) SolidEdgeFramework.Application or SolidEdgePart.PartDocument, etc...

Help files are in \Solid Edge xxx\SDK\*.chm

Using F1 in VB6 when a SE word is selected in your code should launch the SE help topic related to it.

F2 will also help you navigating through SolidEdgeFramework or any other Solid Edge library and will show you all the properties and methods in it.

Regards,

Julian

 

Posted by: Julian Guillo
Post date: 7/8/2009 10:01:41 PM

RE: Solid edge macro for part Copy

[ Edited ]

 

OK, but when i declare as SolidEdgeFramework.Application and SolidEdgePart.PartDocument it isn't work. why?

 

Posted by: kon mar
Post date: 7/8/2009 10:52:05 PM

RE: Solid edge macro for part Copy

[ Edited ]

You must add the references in VB6 like i wrote before:

 

add the Reference libraries needed for Solid Edge in the VB6 menus:

Project --> References.

A form appears with a list in it.

Look into the list for lines containing "Solid Edge xxxxxx" and check them all. Accept.

The lines look like "Solid Edge Assembly Type Library" "Slid edge Framework library", etc.

You don't need all of them for every project but if you check them all you will not fail

You will learn what exact libraries you need for your projects in the future.

 

Posted by: Julian Guillo
Post date: 7/9/2009 5:45:35 AM

RE: Solid edge macro for part Copy

[ Edited ]

You may still need to Dim oPar As Object if you want Julians code to work with sheet metal parts as well as regular parts.

 

Posted by: Dave Rothan
Post date: 7/9/2009 7:07:51 AM

RE: Solid edge macro for part Copy

[ Edited ]

Hi again!

 

There is a new task. I have to hide the reference planes and i have to take the copied part in ISO view.

I found in the Sesdk file many codes included those ones you wrote, when you send me that:

 

oPar.Models.AddCopiedPart FileName

oPar.Models(1).CopiedParts(1).BreakLinks

 

It works, but in the Sesdk help file contains these:

 

AddCopied Method

Syntax

Object.AddCopiedPart(FileName, Xscale, Yscale, Zscale, MirrorOrFlattenPlane, Flatten, FamilyOfPartsMember, CoordinateSystem)

 

BreakLinks Method

Syntax

Object.BreakLinks

 

So how could I know how i have to write a workable macro?

How can I insert new tasks?

 

Posted by: kon mar
Post date: 8/5/2009 2:40:51 AM