By Adam Nagy
When importing geometry from another CAD format like *.step then you cannot specify the transformation for it in the UI. The only thing you can do is transform the geometry in another part document derived from the one that has the imported geometry.
However, using Brian's solution you can achieve that through the API directly in the part document that has the imported geometry. It also takes care of keeping the look of the component the same by copying the Appearance of the original faces:
Public Sub ReorientBaseBody()
Dim partDoc As PartDocument
Set partDoc = ThisApplication.ActiveDocument
Dim pcd As PartComponentDefinition
Set pcd = partDoc.ComponentDefinition
Dim npbfs As NonParametricBaseFeatures
Set npbfs = pcd.Features.NonParametricBaseFeatures' Get the base feature that was created as a result of ' the translation.
Dim baseFeature As NonParametricBaseFeature
Set baseFeature = npbfs(1)' Get the body created by the translation.
Dim originalBody As SurfaceBody
Set originalBody = baseFeature.InputSurfaceBodies(1)' Create a transient copy of the body.
Dim newBody As SurfaceBody
Set newBody = ThisApplication.TransientBRep.Copy(originalBody)
Dim tg As TransientGeometry
Set tg = ThisApplication.TransientGeometry
Dim tr As TransientObjects
Set tr = ThisApplication.TransientObjects
' Define the transform to apply to the body.
Dim trans As Matrix
Set trans = tg.CreateMatrix
Call trans.SetCoordinateSystem( _
tg.CreatePoint(2, 2, 2), tg.CreateVector(0, 1, 0), _
tg.CreateVector(-1, 0, 0), tg.CreateVector(0, 0, 1))' Apply the transform to the transient body.
Call ThisApplication.TransientBRep.Transform(newBody, trans)' Create a new base feature.
Dim baseFeatureDef As NonParametricBaseFeatureDefinition
Set baseFeatureDef = npbfs.CreateDefinition()
Dim inputBodies As ObjectCollection
Set inputBodies = tr.CreateObjectCollection
Call inputBodies.Add(newBody)
baseFeatureDef.BRepEntities = inputBodies
baseFeatureDef.OutputType = kSolidOutputType
Dim newFeature As NonParametricBaseFeature
Set newFeature = npbfs.AddByDefinition(baseFeatureDef)
Dim realBody As SurfaceBody
Set realBody = newFeature.SurfaceBodies(1)
Dim i As Integer
For i = 1 To originalBody.Faces.count
Dim originalFace As Face
Set originalFace = originalBody.Faces(i)
If originalFace.AppearanceSourceType = kOverrideAppearance Then
Dim newFace As Face
Set newFace = realBody.Faces(i)
newFace.Appearance = originalFace.Appearance
End If
Next
' Delete the original feature.
baseFeature.Delete
End Sub