TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ELOQUINTET on April 16, 2004, 12:42:19 PM
-
hey guys don't even know if this is possible but if it is i'm sure you guys have tried it. i need a lisp that would change the insertion point of all blocks in a drawing to 0,0 (IMPORTANT PART) without moving them from their current location? it would be a lifesaver thanks...
-
Have you considered what happens when you have 2 inserts of the same block in a drawing ?
-
yeah i was thinking about that being one of the problems just figured i'd throw my line in the water and see if i get any bites
-
I assume the naming convention for the blocks is important for you ??
There are a couple of options available, but you would need to spell out the crireria and logic exactly before writing a line of code.
-
precisely... you could change all blocks to anonymous blocks... but this will really get nasty when you have nested blocks
-
Hi Keith .. my initial thought was to create a newblock/insert with the prefix being the original block name, and some sort of numerical suffix.
It will all depend on what type of reporting is required and what automation is already in place.
-
Found this:
(defun c:moveblocks (/ instpt ss cntr blklist)
(vl-load-com)
(setq instpt
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbDouble
(cons 0 2)
)
(list 0.0 0.0 0.0)
)
)
)
; create a list of blocks
(if
(setq ss (ssget "_X" '((0 . "INSERT"))))
(progn
(setq cntr 0)
(repeat
(sslength ss)
(setq blklist
(append
(list
(vlax-ename->vla-object (ssname ss cntr))
)
blklist
)
cntr (1+ cntr)
) ; setq
)
) ; progn
)
; remove xref's from list
(if blklist
(progn
(setq blklist
(vl-remove-if
(function
(lambda (x)
(vl-symbolp (vlax-property-available-p x 'Path))
)
)
blklist
)
)
; modify each block in list
(foreach x blklist
(vlax-put-property x 'InsertionPoint instpt)
;(vlax-put-property x 'XScaleFactor 1.0)
;(vlax-put-property x 'YScaleFactor 1.0)
;(vlax-put-property x 'ZScaleFactor 1.0)
(if (not (vlax-object-released-p x))
(vlax-release-object x))
)
); progn
); if
(setq ss nil)
(princ)
); defun
-
well the situation is that i am doing a really complicated stair i grouped different elements of it together as blocks so i can piece the whole thing together but can easily pull the different parts out as i need to coordinate the whole thing. the names are not super important i'm doing it mostly for grouping purposes. i've been creating details then doing a copy with base point then paste as block then making a full section a block. i'll do a saveas and give the lisp a try mark and let you know how it goes. thanks everybody
-
whoa that's not what i wanted. it moved all the blocks to 0,0 but the insertion point is the same. pretty scary to see all those blocks move though :shock:
-
Are the blocks "block" or "wblocks"?
Are they nested into groups? (groups are not the desciding factor on the code to be written)
If I'm getting the jest of what you want to do...
Run a rountine that will find all your "blocks", then, write them out to files as "wblocks" to be used later (is this close??).
If not, explain in detail what you are working with, and what you want to do.
-
what he want exactly in my words,
select all the blocks in the drawing,
the present position of the block should be there only. but when you see the insertion point it should be at 0,0.
for this what we can do is go to eachblock,
take the data of block(means name, rotation,layer etc..)
explode that and make that wblock again but the insertion point you have to give is 0,0.
and insert again.
if you guys got confused about this try manually do all these things first. ok..