Grenco Posted January 7, 2009 Posted January 7, 2009 Hi All For reducing wrong plots (plot settings at my colleagues) I want to make a custom plot command with VBA. I got a Dynamic Block called "Kader" (english = Drawingborder) with Visibility States ("Kaders") called "A3", "A2", "A1", "A0", "A1x3", "A2,3" (as in the paper sizes) Command: list Select objects: 1 found Select objects: BLOCK REFERENCE Layer: "Kader" Space: Model space Handle = 219f6 Block Name: "KADER" Anonymous Name: "*U13" at point, X= 0.0000 Y= 0.0000 Z= 0.0000 X scale factor: 1.0000 Y scale factor: 1.0000 rotation angle: 0 Z scale factor: 1.0000 InsUnits: Millimeters Unit conversion: 1.0000 Scale uniformly: No Allow exploding: Yes Kaders: A3 What I now want to do is make a plot command, wich first looks in to this dynamic block his Visibility State ("Kaders"). When there is "A3" selected, VBA changes the plotdevice and the paper size to A3. When there is "A2" selected, it changes the plotdevice to another plotter and paper size to A2. Etc. for all other paper sizes. The standard help in VBA to handle dynamic blocks isn't helping me because there are no examples and not much information for reading out a Visibility State. Can anyone help me? Thanks a lot! Quote
RickyD302 Posted January 8, 2009 Posted January 8, 2009 I got this code off a some forum......works great hope it helps Dim Props As Variant Dim Idex As Integer With Handle2use ' my block name If .IsDynamicBlock = True Then Props = .GetDynamicBlockProperties Dim index As Variant For index = LBound(Props) To UBound(Props) Dim oprop As AcadDynamicBlockReferenceProperty Set oprop = Props(index) If oprop.PropertyName = "Visibility" Then ' visibility property oprop.Value = strBlkName Exit For End If Next index End If End With Quote
Grenco Posted January 14, 2009 Author Posted January 14, 2009 Thnx for your help Ricky! But why is "dim idex as integer" in the program? It isnt used anywhere else. Another question, "handle2use..."what to do with that? Do I need it to change to "With Handle2Use Kader" (Kader is blockname) And what is strBlkName? I'm new at the (VBA) programming. How can I search my DWG for a blockname? thnx Quote
RickyD302 Posted January 27, 2009 Posted January 27, 2009 My bad...most likely something I was messing with and then forgot to comment it out or delete it. Yes Handle2use is my block strBlkHandle is a string that sets the visibility state that I want. to search for blocks you need to create a selection set Dim fcode(0) As Integer Dim ftype(0) As Variant Dim objss As AcadSelectionSet Dim varBlock as variant Dim objBlock as acadBlock fcode(0) = 0: ftype(0) = "INSERT" ' Looking for Blocks On Error Resume Next ThisDrawing.SelectionSets.Item("FindMyBLocks").Delete On Error GoTo 0 Set objss = ThisDrawing.SelectionSets.Add("FIndMyBlocks") objss .Select acSelectionSetAll, , , fcode, ftype if objss.count > 0 then for each varBlock in objss set objBlock = varBlock '--now at the code previously posted looking for dynamic (need to change names)-- next end if 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.
Note: Your post will require moderator approval before it will be visible.