Now onto the methods for creating reference drawings for the blocks database....
A good reccomendation is to keep the main outline of the block objects on layer zero with colour by layer. This way when inserted the blocks will take on the properties of the current layer.
To set all layers in a drawing including inside a block you can use this code:
- (defun c:fixblocks( / b1 name ent elist a8 a62) (setq b1 (tblnext "BLOCK" t)) (while b1 (princ (strcat "\n" (setq name (cdr (assoc 2 b1))))) (setq ent (tblobjname "block" name) ent (entnext ent)) (while ent (setq elist (entget ent)) (setq elist (if (setq a8 (assoc 8 elist)) (subst (cons 8 "0") a8 elist))) (setq elist (if (setq a62 (assoc 62 elist)) (subst '(62 . 0) a62 elist))) (setq elist (entmod elist)) (setq ent (entnext ent)) ) (setq b1 (tblnext "BLOCK")) ) (princ) )
Now if the blocks have other layers like centerlines, invisible lines etc a different method can be employed.
I would isolate the layer that I want to change and open block by block (tedious yes... ) and use cui to associate a set to layer 0 code to a shortcut key
- ^C^C(command "layer" "set" "0" "" "laycur" "all" "" "bclose" "save")
And finally to avoid scaling errors two steps should be made.
1. Set all of your created blocks to unitless. The following script cean be used to complete the task.
- (vl-load-com)(vlax-for x(vla-get-Blocks(vla-get-activedocument (vlax-get-acad-object)))(vlax-put-property x "Units" 0))(setvar "insunits" 0)(setvar "insunitsdeftarget" 0)(setvar "insunitsdefsource" 0)
2. Create a tool that can do the same thing in AutoCAD since some drawings come with embedded setting for insertion scale.
I used the following script and added it as a tool to the toolbar for switching tool palette groups.
- ^C^C(command "insunits" "4")(command "insunitsdefsource" "4")(command "insunitsdeftarget" "4")
*** ONCE AGAIN I TAKE NO CREDIT FOR ANY OF THE CODES.. I JUST JUMBLED THEM TOGETHER AND AM TRYING TO PROVIDE THEM FOR OTHERS IN ONE NEAT BUNDLE*** |