VBA Intellicad version of "BlockRef" and "AttributeRef"

Sorry I am taking up so much of this discussion board on the same thing. But, I am really stuck and need to make some progress on this.I am reading an article extracting block attributes using VBA with AutoCAD. There are two terms I can't find when I look at the VBA inside BricsCad. Is there an exact substitute? Perhaps the entire process for extracting Attributes in IntelliCAD is different from AutoCAD, and that is why I am not having any success.The terms in question are, "BlockRef" and "AttributeRef"Here is the portion of the article where they are used;-----There is a method called GetAttributes associated with the BlockRef object that will return a variant array of AttributeRef objects. Changing the properties TextString and TagString can modify each AttributeRef object as needed. Additional properties are in the AttributeRef that can be modified just as the entity list manipulations have demonstrated.------Joe Dunfee

Comments

  • Joe,below I added some excerpts from a Numbering tool written in VB which modifies text and attributes and sets them to a desired number. I hope these excerpts give you insight in how to proceed.Kind regards,Hans De Backer--------------------------------------------------------Public CadApp As IntelliCad.ApplicationPublic Sub Main() On Error Resume Next If Nothing Is CadApp Then Set CadApp = GetObject(, "icad.application") If Nothing Is CadApp Then MsgBox ("Could not get CadApp reference during Main init. BricsCad not loaded?") Else FrmNumberingTool.Show vbModal End IfEnd Sub'excerpt from the FrmNumberingTool form codePrivate Sub CmdReplaceNumber_Click() Me.Hide Call GetEntityToReplace InitDialogFromSetting gCurrentSetting, True Me.ShowEnd Sub'---------------------------------------------------------------' set up a loop to let the user pick an entity in the' current DWG; if the user selects an entity pass it on for' further processing else show the form again' Note: this function is rather clumsily written - please rework'---------------------------------------------------------------Sub GetEntityToReplace() Dim thisdrawing As IntelliCad.Document Set thisdrawing = CadApp.ActiveDocument Dim keepGoing As Boolean keepGoing = True Dim my_Ent As Entity Dim pt1 As Point Do While keepGoing On Error Resume Next With thisdrawing.Utility .GetEntity my_Ent, pt1, vbCr & "next text replacement = " & gCurrentSetting.Numbering If my_Ent Is Nothing Then 'user misses or right-clicks or Esc Exit Sub End If .Prompt vbCr & vbCr & "pick text (Esc, miss or right-click to return to settings)" & _ "you selected: " & my_Ent.EntityName Call Replace(my_Ent) End With Set my_Ent = Nothing 'thisdrawing.Regen LoopEnd SubFunction Replace(ent As Entity) If ent.EntityType = vicText Then Call ReplaceText(ent) ElseIf ent.EntityType = vicBlockInsert Then Call ReplaceAttribute(ent, gCurrentSetting.AttributeName) End IfEnd FunctionFunction ReplaceText(txt As IntelliCad.Text) txt.TextString = gCurrentSetting.Numbering txt.Update gCurrentSetting.IncrementNumber StoreNextNumber gCurrentSetting, gDictNextNumbersEnd FunctionFunction ReplaceAttribute(oInsert As IntelliCad.BlockInsert, sAttributeName As String) Dim oAttribs As IntelliCad.Attributes Dim i As Integer If oInsert.HasAttributes Then Set oAttribs = oInsert.GetAttributes If Len(sAttributeName) > 0 Then For i = 1 To oAttribs.count If UCase(oAttribs.Item(i).TagString) = UCase(sAttributeName) Then oAttribs.Item(i).TextString = gCurrentSetting.Numbering oAttribs.Item(i).Update gCurrentSetting.IncrementNumber StoreNextNumber gCurrentSetting, gDictNextNumbers End If Next i Else ' no attribute name was passed in -> replace any attribute found For i = 1 To oAttribs.count oAttribs.Item(i).TextString = gCurrentSetting.Numbering oAttribs.Item(i).Update gCurrentSetting.IncrementNumber StoreNextNumber gCurrentSetting, gDictNextNumbers Next i End If End IfEnd Function

This discussion has been closed.