Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi. I'm having trouble with projecting geometry to a part sketch from the geometry belonging to a different part within an assembly. Essentially, I am trying to mimic "Project Geometry" to create a cross-part reference in a sketch.
The code below works if the entity selected on line 16 belongs to the same part, but not if it belongs to a different part. I haven't found any info on this in the forums.
Can someone help me with this, please?
Dim oAssemDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oAssemDef As AssemblyComponentDefinition = oAssemDoc.ComponentDefinition
Dim oFace As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select face on part for new sketch") 'Selected face on part document
Dim oOcc As ComponentOccurrence = oFace.ContainingOccurrence
oOcc.Edit
Dim oPartDoc As PartDocument = ThisApplication.ActiveEditDocument 'Active part document within an open assembly
Dim oPartDef As PartComponentDefinition = oPartDoc.ComponentDefinition
If TypeOf oFace Is FaceProxy Then oFace = oFace.NativeObject 'If part is within an assembly
Dim oSketch As PlanarSketch = oPartDef.Sketches.Add(oFace)
oSketch.Edit
Dim oEntity As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Select entity to project") 'Selected entity from another part within assembly
If Right(TypeName(oEntity), 5) = "Proxy" Then oEntity = oEntity.NativeObject 'If part is within an assembly
oSketch.AddByProjectingEntity(oEntity) 'Error if entity is from a different part
Solved! Go to Solution.