PhillO
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
how do access say a titleblock block for example that is in a layout?
Phill
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.
@ = alphebetic character;
# = numeric character;
? = a single character wildcard; and,
* = multiple character wildcard.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.GetEnt ity 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
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.GetEnt
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 .
looks good and I think youre right about thisdrawing.paperspace .
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.
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.
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.
ASKER
Hi Norrin
Yes thankyou, your code did help. In fact it help solve a couple of other issues as well
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
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.