pop3k Posted July 2, 2021 Report Posted July 2, 2021 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 Quote
kruszynski Posted July 2, 2021 Report Posted July 2, 2021 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 dmatusz3 1 Quote
pop3k Posted July 2, 2021 Author Report Posted July 2, 2021 Jeżeli ssetObj jest moim oSset to wyskakuje mi błąd Run-time error '-2147467259 (80004005)': Method 'Item" of object "IZcadSelectionSet' failed -> Set ent = oSset.item(i) Quote
pop3k Posted July 2, 2021 Author Report Posted July 2, 2021 Ok, znalazłem. Za dużo pętli w For I = 0 To ssetObj.Count powinno być For I = 0 To ssetObj.Count -1 Dziękuję bardzo. Ładnie działa! dmatusz3 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.