Jump to content
Sign in to follow this  
Karol

Removing lines crossing object

Recommended Posts

Karol

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


 

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Sign in to follow this  

×
×
  • Create New...