Jump to content

Removing lines crossing object


Karol

Recommended Posts

Hi, its my first time in vba programming. I try to resolve some problem. 
I have solid project with sphere and lines. I want to cut all lines crosing my sphere. 
How can i check condition lines crossing my object (sphere). Im studied documentation and i found .IntersectWith method. Can i use this?
I prepared some code but i have error "object required". Someone can help me ?. Thanks for advice 


Sub test()

Dim selectionSetLine As AcadSelectionSet
Dim sphere As Acad3DSolid
Dim acadEntity As acadEntity
Dim intPoints As Variant
Dim selectPnt As Variant

ThisDrawing.Utility.GetEntity acadEntity, selectPnt, "Select sphere"

Set selectionSetLine = ThisDrawing.SelectionSets.Add("line")
selectionSetLine.SelectOnScreen

Call checkInterference(acadEntity, selectionSetLine)

End Sub

Public Sub checkInterference(model As acadEntity, lines As AcadSelectionSet)

    Dim intPoints As Variant
    Dim acadLine As acadLine
    Dim sphere As Acad3DSolid
    Dim object As Object
    
    Set sphere = model
    
    MsgBox "procedure check"
    
    For Each object In lines
        If obj.ObjectName = "AcDbLine" Then
            Set acadLine = object
            MsgBox "test"
            intPoints = acadLine.IntersectWith(sphere, acExtendBoth)
            MsgBox "test"
            'toDo condition remove line like this'
                'If VarType(intPoints) <> vbEmpty Then'
                'MsgBox "test"'
                'acadLine.Delete'
                'End If'
            Else: MsgBox "There are no line object"
        End If
    Next
End Sub


 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...