Link to home
Start Free TrialLog in
Avatar of PhillO
PhillOFlag for Australia

asked on

AUTOCAD vba paperspace entities

I want to cycle through drawings layouts to get block names for a vba program

how do access say a titleblock  block for example that is in a layout?

Phill
Avatar of dhsindy
dhsindy
Flag of United States of America image

All block names available in any layout or model space.  At the command line type the word block; then a ?; then, and *.  Keep hitting the enter key until done.

Also, if you turn of file logging on the format tab, everything that scrolls across will be saved in it (an ASCII file).  Which of course you can cut, paste, and edit.
I meant turn ON logging - I think thats on the FORMAT/OPEN AND SAVE tab on the lower left.  Also, in the BLOCK command you can use the standard AutoCAD wildcards:

@ = alphebetic character;
# = numeric character;
? = a single character wildcard; and,
* = multiple character wildcard.
SOLUTION
Avatar of dhsindy
dhsindy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PhillO

ASKER

Hi Norrin

According to the autocad vba docs ( as I understand it) ThisDrawing.paperspace refers only to the active layout. So to get through all the paperspace layouts I have to  do some thing like

    ThisDrawing.Utility.GetEntity blk, pnt, "Select block:"
   
    If blk.entityType = acBlockReference Then
        BlockName = blk.Name
        For Each layout In ThisDrawing.layouts
            For Each ent In layout.block
                If ent.entityType = acBlockReference Then
                    If ent.Name = BlockName Then ent.Delete
                End If
            Next
        Next
    End If

Is that right or have I misread it


BTW this code allows a user to to select a block and delete every reference to it... that's all it does. It actually works but I'm not sure if the methodology is correct
that looks good to me. if "that's all it does" (pretty powerful if you ask me ;)) and it works the way it is to delete every reference then it should work to edit them or get the names or whatever you want to do to them. just replace the "If ent.Name = BlockName Then ent.Delete" part with what you want to do.

looks good and I think youre right about thisdrawing.paperspace .
Avatar of PhillO

ASKER

I'm not sure what you mean by "(pretty powerful if you ask me ;))

Ultimately it can be used for other things as well like replacing blocks etc.
when I said "(pretty powerful if you ask me ;))" I thought you were downplaying that routine is all.

anyway, did my code help you at all or did you get it on your own? i was trying to get something worked up earlier but never got to it. looks like you got the idea.
Avatar of PhillO

ASKER

Hi Norrin

Yes thankyou, your code did help. In fact it help solve a couple of other issues as well

thanks for the points and the grade. glad to help