Copy a face/surface from a part....(Anyone?)

Copy a face/surface from a part....(Anyone?)

Anonymous
Not applicable
553 Views
1 Reply
Message 1 of 2

Copy a face/surface from a part....(Anyone?)

Anonymous
Not applicable
Hi to all.
I want to copy a face/surface from a part by picking it then a new part document is opened and display the copied surface. Pls. see attached jpg file.

Is this possible in vba?

Thank you in advance.
Ber Message was edited by: BernaJeanne
0 Likes
554 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
The sample below uses some new functionality available in Inventor 2009
called Transient B-Rep. This lets you do some solid/surface manipulation
outside of the context of a part or command. It's currently very limited
but does provide some basic functionality. In this case, I use the Copy
method to copy the face from the part to new transient SurfaceBody and then
use this to create a non-parametric base feature in a new part. This is
equivalent to reading in a foreign file (STEP, IGES, SAT, etc.) that
contained the surface.

Public Sub CopySelectedFace()
Dim oSourcePartDoc As PartDocument
Set oSourcePartDoc = ThisApplication.ActiveDocument

' Get the selected face.
On Error Resume Next
Dim oFace As Face
Set oFace = oSourcePartDoc.SelectSet.Item(1)
If Err Then
MsgBox "A face must be selected."
Exit Sub
End If
On Error GoTo 0

' Copy the face as a transient B-Rep face.
Dim oNewBody As SurfaceBody
Set oNewBody = ThisApplication.TransientBRep.Copy(oFace)

' Create a new part.
Dim oTargetPartDoc As PartDocument
Set oTargetPartDoc = ThisApplication.Documents.Add(kPartDocumentObject,
_
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))

' Create a non-parametric base feature using the face.
Dim oNPFeature As NonParametricBaseFeature
Set oNPFeature =
oTargetPartDoc.ComponentDefinition.Features.NonParametricBaseFeatures.Add(oNewBody)
End Sub

--
Brian Ekins
Autodesk Inventor API
0 Likes