
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I've been using VBA to automate AutoCAD for a little while now, but this issue is baffling me. I have a function that looks through the blocks in paperspace to find a specific block containing one attribute, and then makes that block visible/invisible based on a value from the Custom Drawing Properties.
Sub TexasFirm() 'This is a function that checks the state of the project and, if not in Texas, removes the Texas Firm block
Dim entity As AcadEntity
Dim bref As AcadBlockReference
Dim objLayout As AcadLayout
Set objLayout = ThisDrawing.ActiveLayout
Dim Value As String ThisDrawing.SummaryInfo.GetCustomByKey "Project City State Zip Code", Value
If objLayout.name <> "Model" Then For j = 0 To objLayout.block.Count - 1 Set entity = objLayout.block.Item(j) If TypeOf entity Is AcadBlockReference Then Set bref = entity If bref.EffectiveName = "TEXAS FIRM BLOCK" Then If UCase(Value) Like "*TEXAS*" Or Value Like "*TX*" Or Value = "" Then bref.Visible = True
bref.Update Exit For Else bref.Visible = False bref.Update Exit For End If End If End If Next End If End Sub
This function worked perfectly until I updated to AutoCAD 2018. Now, it still finds the block and checks through my conditions as expected, but the "bref.visible = false" line executes and makes no change. The block is a simple block with a single attribute that contains a number that doesn't need to be shown if the job is not in Texas. I also tried changing the visibility from the attribute level (as opposed to the block reference level), but the HasAttributes() method is not returning the one attribute that comprises the block.
For now, my solution has just been to delete the block, but I don't really like doing that, and everything worked before updating AutoCAD... Any ideas?
Solved! Go to Solution.