Using iLogic to trim lines/curves found outside of specific geometry

Using iLogic to trim lines/curves found outside of specific geometry

chewy_robot
Contributor Contributor
288 Views
0 Replies
Message 1 of 1

Using iLogic to trim lines/curves found outside of specific geometry

chewy_robot
Contributor
Contributor

Hello,

I have an iLogic rule that runs in a sketch environment on a part that is being edited in an assembly. It automatically projects all cut edges on that sketch plane of parts that intersect with that plane, this all works no problem. I want to take it a step further and somehow trim (ideally) all lines/curves/geometry found outside of the projected cut edge loop it creates. What I am trying to do is have a quick button that will quickly create scribelines on a sheet metal flat pattern part. Any ideas on how this can be achieved? In the picture i've attached, the code would detect and eliminate the geometry found outside of the yellow projected loop (which is called Project Cut Edges) and leave the remaining geometry inside left aloneScreenshot_3.jpg

Dim oApp As Inventor.Application = ThisApplication
Dim oPart As PartDocument = ThisDoc.Document
Dim oSketch As Sketch = TryCast(oApp.ActiveEditObject, Sketch)

If oSketch Is Nothing Then
    MessageBox.Show("A sketch must be active.")
    Exit Sub
End If

' Remember the sketch name for later
Dim sketchName As String = oSketch.Name

' Get the parent assembly of the part
Dim oParentAsm As AssemblyDocument = Nothing
For Each oDoc As Document In oApp.Documents.VisibleDocuments
    Dim oAsm As AssemblyDocument = TryCast(oDoc, AssemblyDocument)
    If oAsm IsNot Nothing Then
        For Each oOcc As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences
            If oOcc.ReferencedDocumentDescriptor.FullDocumentName = oPart.FullDocumentName Then
                oParentAsm = oAsm
                Exit For
            End If
        Next
    End If
    If oParentAsm IsNot Nothing Then Exit For
Next

' Select the parts and subassemblies in the parent assembly if they are visible
If oParentAsm IsNot Nothing Then
    oParentAsm.Activate()
    For Each oOcc As ComponentOccurrence In oParentAsm.ComponentDefinition.Occurrences
        If oOcc.Visible Then ' Check if the occurrence is visible
            oApp.CommandManager.DoSelect(oOcc)
        End If
    Next
End If

' Execute the "Project Cut Edges" command
Try
    oApp.CommandManager.ControlDefinitions.Item("SketchProjectCutEdgesCmd").Execute2(True)
Catch ex As Exception
    MessageBox.Show("Error executing the 'Project Cut Edges' command: " & ex.Message)
End Try

 

0 Likes
Replies (0)