Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Could you help me?
I'm trying to write code that will project geometry from a component to another that is inserted into an assembly.
I select components from the assembly and their sketches with the same name (for example cut_type 1 or type 2). Then I select another component and its plane. Then you need to project the geometry from the component sketch onto the plane of another component.
The following code does not project geometry.
Thanks for the advice
Sub Main Dim oAsm As AssemblyDocument = ThisApplication.ActiveDocument Dim oAsmComp As AssemblyComponentDefinition = oAsm.ComponentDefinition Dim oOcc As ComponentOccurrence oOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select part with sketch") Dim oPartComp As PartComponentDefinition oPartComp = oOcc.Definition If oOcc Is Nothing Then Return Dim oSketch As Sketch = Nothing Dim SketchList As New ArrayList For Each oSketchTemp As Sketch In oPartComp.Sketches SketchList.Add(oSketchTemp.Name) Next If SketchList.Count = 0 Then Return Dim sSketch As String = InputListBox("Sketches found on the selected part", SketchList, "", "Select sketch for part", "Sketch Found") If sSketch = "" Then Return oSketch = oPartComp.Sketches.Item(sSketch) Dim oOcc2 As ComponentOccurrence oOcc2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select part to projected sketch to") Dim oPartComp2 As PartComponentDefinition oPartComp2 = oOcc2.Definition Dim WPList As New ArrayList For Each oWP As WorkPlane In oPartComp2.WorkPlanes WPList.Add(oWP.Name) Next Dim WP As String = InputListBox("Work planes found on the selected part", WPList, "", "Select a work plane to create sketch", "Work Planes Found") If WP = "" Then Return Dim oWP2 As WorkPlane' = oPartComp2.WorkPlanes.Item(WP) oWP2 = oPartComp2.WorkPlanes.Item(WP) '''Dim oSketches2 As PlanarSketches = oPartComp2.Sketches ''??????????? Dim oSketch2 As Sketch ' = oSketches2.Add(oWP2) oSketch2 = oPartComp2.Sketches.Add(oWP2) oSketch2.Name = "New Sketch" PlanarSketchProxy.AddByProjectingEntity(oSketch2) End Sub
Solved! Go to Solution.