Hey,
im curious as to what i have to change to get it to look in paper space instead of model?
ive tryed changing
For Each bobj In ThisDrawing.ModelSpace
to
For Each bobj In ThisDrawing.ActiveLayout
but i just get errors. any help would be great thanks.
Hi, I'm trying to switch off/on the visibility of my block, but I'm trying to do this with a command Button. How do I make this?
I would like to click in a Check box, activating and deactivating the visibility, of various dynamics blocks. For example 4 dynamic blocks. How can I do it?
Private Sub CommandButton1_Click()
Dim dybprop As Variant
Dim i As Integer
Dim bobj As AcadEntity
For Each bobj In ThisDrawing.ModelSpace
If bobj.ObjectName = "AcDbBlockReference" Then
If bobj.IsDynamicBlock Then
If bobj.EffectiveName = "Luminaria_Dinamica" Then
dybprop = bobj.GetDynamicBlockProperties
For i = LBound(dybprop) To UBound(dybprop)
If dybprop(i).PropertyName = "Visibility" Then
dybprop(i).Value = "leader off"
End If
Next i
End If
End If
End If
Next
For Each bobj In ThisDrawing.ModelSpace
to
For Each bobj In ThisDrawing.ActiveLayout.block
Might seem unlogical at first, but the 'block' part of a layout contains all the geometry and is the equivalent of 'ModelSpace'. 'PaperSpace' would work too, but ActiveLayout.block is more universal.
Hello everyone, I am trying to do something very similar to the original macro provided but for some reason it's not working for. I think this might be a simple solution but I just wanted to see if you guys have some input, as i am running out of ideas. Any and all help will be appreciated. Thanks!
You need to tell us more than "Its not working". What errors are you getting? I see you are in break mode. What line is failing to complete? Describe your problem in more detail.
Thank you for replying so quickly! When I try to run it I get the "Run time error '424': Object Required"; Messagebox gives me the option to end or debug, I click end and nothing happens or I click debug and it highlights "For Each bobj In ThisDrawing.ModelSpace". I'm not sure what the problem is because I also have turned on the references to the AutoCAD libraries so I think it should be able to understand the autocad references. I'm not sure what the issue is. I have another code I use (to insert blocks) where the libraries are not needed ( non-binding, i think it's called) and the autocad references are dimmed as objects and such and I'm not sure if maybe I should try to translate this code into that manner. But with this code i am trying to incorporate control over visibility. Please let me know if
I missed anything, thank you!
The code you show in your last post doesn't appear to have anything to do with your first post. However, it looks like you are running inside xl. The ThisDrawing object doesn't exist in xl. You need to dim it and then instantiate it via
Set ThisDrawing = AcadApplication.ActiveDocument
Also, when you show code, don't give us a picture of it. Paste the actual code into a code window using the </> symbol on the reply toolbar.
Correct, the code in the last picture doesnt have anything to do with this one I just wanted to show you a reference of how I got blocks to be inserted in a different code. Also, you're right, I am doing this via Excel. Now I've dimmed ThisDrawing As AcadDocument and the code doesn't break when I run it anymore, but now nothing is happening, no the dynamic block on AutoCAD is not changing at all. Here's what I have :
Private Sub ScanBlks() Dim dybprop As Variant, i As Integer Dim bobj As AcadEntity Dim ThisDrawing As AcadDocument Set ThisDrawing = AcadApplication.ActiveDocument For Each bobj In ThisDrawing.ModelSpace If bobj.ObjectName = "AcDbBlockReference" Then If bobj.IsDynamicBlock Then If bobj.EffectiveName = "FSM4L-ENDCAPS" Then dybprop = bobj.GetDynamicBlockProperties For i = LBound(dybprop) To UBound(dybprop) If dybprop(i).PropertyName = "Visibility" Then dybprop(i).Value = "FSM4L-TF-ENDCAP" End If Next i End If End If End If Next End Sub
Can you post a dwg with your block in it?
Yes I can. Thank you!
I sure can, Thank you!
I made the following changes in red.
Public Sub ScanBlks() Dim dybprop As Variant, i As Integer Dim bobj As AcadEntity Dim ThisDrawing As AcadDocument Set ThisDrawing = AcadApplication.ActiveDocument For Each bobj In ThisDrawing.ModelSpace If bobj.ObjectName = "AcDbBlockReference" Then If bobj.IsDynamicBlock Then If bobj.EffectiveName = "FSM4L-ENDCAPS" Then dybprop = bobj.GetDynamicBlockProperties For i = LBound(dybprop) To UBound(dybprop) If dybprop(i).PropertyName = "Visibility1" Then dybprop(i).Value = "FSM4L-TF-ENDCAP" ThisDrawing.Regen acActiveViewport End If Next i End If End If End If Next