[VBA] Zwcad - zaznacz blok ale uważaj na grupy


Recommended Posts

Cześć, używam kodu do zaznaczania bloków i filtruje je aby pobierało tylko te z nazwą "test". Czasem bloki te grupuję. Czy makro może wychwycić, że dany blok o nazwie "test" jest już w jakiejś grupie, wyrzuci mi błąd (msgbox) i wyjdzie z funkcji?

Dim oSset As ZcadSelectionSet
          With ThisDrawing.SelectionSets
               While .count > 0
                    .item(0).Delete
               Wend
          Set oSset = .Add("*")
          End With
           
          ftype(0) = 2: fdata(0) = "test"
          dxfCode = ftype: dxfValue = fdata

    oSset.SelectOnScreen dxfCode, dxfValue

 

Link to comment
Share on other sites

Trzeba sprawdzić porównać wybrane elementy z każdym elementem w każdej grupie.

    Dim ent As ZcadEntity
    For I = 0 To ssetObj.Count
        Set ent = ssetObj.Item(I)
    
        Dim grs As ZcadGroups
        Dim gr  As ZcadGroup
    
        Set grs = ThisDrawing.groups    
        For Each gr In grs
            For J = 0 To gr.Count
                Dim entwgrupie As ZcadEntity
                Set entwgrupie = gr.Item(J)
                If entwgrupie Is ent Then
                    MsgBox "element jest w grupie"
                    Exit Sub
                End If
            Next J
        Next
    Next I
    

 

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.

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.

Loading...