Creating a copy of an object

Hi All,
is there a way to copy an object, for example a curve with API?
Maybe something similar to the UFModl.CreateCurveFromEdge Method?
Thanks!

Record a journal while using the 'move object' command; be sure to select the 'create a copy' option. The resulting code should point you in the right direction.

Using SNAP, it's just object.Copy().

With NX/Open, the usual technique is to use a transformation that has zero effect (e.g. move with a vector equal to zero, or sacle with a factor = 1). Use NXOpen.UF.UFModl.TransformEntities.

Thanks for your comments!
@ciao: I have not found the "NXOpen.UF.UFModl.TransformEntities" function in the API Namespace.
Is it in a newer NX Version? I'm working with NX8.
Thanks again!

In the .net API reference, activate the "index" tab and type in "TransformEntities"; the help page for the wrapper function will be the first result. The link to the UF (UF_MODL_transform_entities) seems to be broken. Calling it in VB.net would look something like this:





theUfSession.Modl.TransformEntities(integerNumberOfEntities, entityTags, trasformMatrix)





I recorded a journal using the move object command and cut out the fluff from the resulting code. You'll need to remove the selection stickiness; it looks for a certain line object in a part that I happened to have open at the time.



Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

Dim displayPart As Part = theSession.Parts.Display

' ----------------------------------------------
' Menu: Edit->Move Object...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim nullFeatures_MoveObject As Features.MoveObject = Nothing

If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw(New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))
End If

Dim moveObjectBuilder1 As Features.MoveObjectBuilder
moveObjectBuilder1 = workPart.BaseFeatures.CreateMoveObjectBuilder(nullFeatures_MoveObject)

moveObjectBuilder1.TransformMotion.Option = GeometricUtilities.ModlMotion.Options.DeltaXyz

moveObjectBuilder1.TransformMotion.DeltaEnum = GeometricUtilities.ModlMotion.Delta.ReferenceWcsWorkPart

moveObjectBuilder1.TransformMotion.DeltaXc.RightHandSide = "0"

moveObjectBuilder1.TransformMotion.DeltaYc.RightHandSide = "0"

moveObjectBuilder1.TransformMotion.DeltaZc.RightHandSide = "0"

moveObjectBuilder1.MoveObjectResult = Features.MoveObjectBuilder.MoveObjectResultOptions.CopyOriginal

moveObjectBuilder1.Layer = 1

moveObjectBuilder1.MoveParents = False

theSession.SetUndoMarkName(markId1, "Move Object Dialog")

Dim origin1 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim vector1 As Vector3d = New Vector3d(0.0, 1.0, 0.0)
Dim direction1 As Direction
direction1 = workPart.Directions.CreateDirection(origin1, vector1, SmartObject.UpdateOption.WithinModeling)

moveObjectBuilder1.TransformMotion.DistanceVector = direction1

Dim line1 As Line = CType(workPart.Lines.FindObject("HANDLE R-502393"), Line)

Dim added1 As Boolean
added1 = moveObjectBuilder1.ObjectToMoveObject.Add(line1)

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Move Object")

theSession.DeleteUndoMark(markId2, Nothing)

Dim nXObject1 As NXObject
nXObject1 = moveObjectBuilder1.Commit()

Dim objects1() As NXObject
objects1 = moveObjectBuilder1.GetCommittedObjects()

theSession.SetUndoMarkName(markId1, "Move Object")

moveObjectBuilder1.Destroy()

End Sub
End Module



The origin1, vector1, and direction1 stuff could probably also be removed without any ill effects.