Are you allowed to create any geometry? Not as clean as what you
want but that's what I do. Get the face reference, add it as a
surfacedatum, make an extract, select the extract.
Dim sel_SourceFaceToProject As Selection
sel_SourceFaceToProject = myProductDocument.Selection
sel_SourceFaceToProject.Clear()
sel_SourceFaceToProject.Add(objCol.Item(i).Value)
'get the source part info from selection
Dim sourcePartProduct As Product
sourcePartProduct =
sel_SourceFaceToProject.Item2(1).LeafProduct
Dim SourcePartDocument As PartDocument
SourcePartDocument = sourcePartProduct.ReferenceProduct.Parent
Dim SourcePart As Part
SourcePart = SourcePartDocument.Part
Dim SourcePartDocumentName As String
SourcePartDocumentName = SourcePartDocument.Name
Dim ref_SourceFaceToProject As Reference
ref_SourceFaceToProject =
sel_SourceFaceToProject.Item2(1).Reference
'add to reference the product path
Dim ProductPath As String
Dim GeometryPath As String
Dim pos As Integer
Dim ref_GeomInProduct As Reference
Dim brepName As String
brepName = GetCorrectedBREPName(ref_SourceFaceToProject.Name)
ref_SourceFaceToProject =
targetPart.CreateReferenceFromBRepName(brepName,
ref_SourceFaceToProject.Parent)
ProductPath = GetInstanceAbsolutePath(sourcePartProduct, "")
GeometryPath =
SourcePart.Parameters.GetNameToUseInRelation(ref_SourceFaceToProject)
GeometryPath = Replace(GeometryPath, "", "/")
pos = InStrRev(GeometryPath, "/")
'GeometryPath = Left(GeometryPath, pos - 1) & "/!" &
Mid(GeometryPath, pos + 1, Len(GeometryPath) - pos + 1)
ref_GeomInProduct = myProduct.CreateReferenceFromName(ProductPath
& "!" & GeometryPath)
'ref_GeomInProduct = myProduct.CreateReferenceFromName(ProductPath
& GeometryPath)
Dim targetHShapes As HybridShapes
targetHShapes = targetHBody.HybridShapes
'create Surface of source part surface
Dim targetHSSExplicit As HybridShapeSurfaceExplicit
targetHSSExplicit =
targetHSFactory.AddNewSurfaceDatum(ref_SourceFaceToProject)
targetHSSExplicit.Compute()
'targetHSSExplicit.object =
'targetHSSExplicit.surface =
'create extract of source part surface
Dim targetHSExtract As HybridShapeExtract
targetHSExtract =
targetHSFactory.AddNewExtract(ref_SourceFaceToProject)
targetHSExtract.Compute()
targetHSExtract.PropagationType = 3
targetHSExtract.ComplementaryExtract = False
targetHSExtract.IsFederated = False
'add the extract to the geoset
targetHBody = targetHBodies.Item("REFERENCE GEOMETRY")
targetHBody.AppendHybridShape(targetHSExtract)
targetPart.Update()
targetPart.InWorkObject = targetHSExtract