Message 1 of 8

Not applicable
07-03-2019
01:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I hope someone can help me.
I have made a VBA routine that needs to get an ObjectID of an AcadDynamicBlockReferenceProperty.
If i replace:
ThisDrawing.Utility.Prompt dybprop(i).ObjectID & vbCrLf
for:
ThisDrawing.Utility.Prompt dybprop(i).PropertyName & vbCrLf
it returns all the names of the customproperties of the dynamic block.
I want to get the objectID so i can create a field (ObjectARX) and place it into an attribute.
Here my full VBA code:
Sub CreateFieldFromAtt_SWDEG() Dim ss As AcadSelectionSet Dim dybprop As Variant Dim i As Integer Dim bobj As AcadEntity Dim inspt As Variant 'Dim i Dim EObjId As String Dim ErrorCount As Integer Dim ErrorDataCount As Integer ErrorCount = 0 ErrorDataCount = 0 On Error Resume Next Set ss = ThisDrawing.SelectionSets.Add("SS2") ss.SelectOnScreen For Each bobj In ss If bobj.ObjectName = "AcDbBlockReference" Then 'Clear EObjId = "" Set oBlkRef = bobj If oBlkRef.IsDynamicBlock Then dybprop = oBlkRef.GetDynamicBlockProperties For i = LBound(dybprop) To UBound(dybprop) ThisDrawing.Utility.Prompt dybprop(i).ObjectID & vbCrLf If dybprop(i).PropertyName = "Angle1" Then ThisDrawing.Utility.Prompt "heeft Angle1" & vbCrLf EObjId = dybprop(i).ObjectID End If Next i 'Error Check If EObjId = "" Then ThisDrawing.Utility.Prompt "Geen SENSOR_TYPE ObjectID" & vbCrLf ErrorCount = ErrorCount + 1 GoTo Error End If AttList = oBlkRef.GetAttributes For i = LBound(AttList) To UBound(AttList) If AttList(i).TagString = "SENSOR_TYPE" Then EString = "%<\AcObjProp Object(%<\_ObjId " & EObjId & ">%).TextString>%" AttList(i).TextString = EString & " " & SString & "-" & NString ErrorDataCount = 0 Exit For Else ErrorDataCount = 1 End If Next If ErrorDataCount = 1 Then ThisDrawing.Utility.Prompt "Geen DATAPUNT_NAAM attribute" & vbCrLf ErrorCount = ErrorCount + 1 GoTo Error End If Error: End If End If Next ThisDrawing.Regen acAllViewports If ErrorCount = 1 Then MsgBox "Er is 1 block waar een fout is opgetreden. Bekijk de commandline." ElseIf ErrorCount > 1 Then MsgBox "Er zijn " & ErrorCount & " blocken waar een fout is opgetreden. Bekijk de commandline." End If ss.Clear ThisDrawing.SelectionSets("SS2").Delete End Sub
Solved! Go to Solution.