CadFrank Posted November 12, 2013 Posted November 12, 2013 Hi, does anyone know of a routine to insert multiple block's in the basepoint of other blocks. Quote
Lee Mac Posted November 12, 2013 Posted November 12, 2013 A simple enough program to write, but to offer an existing solution: you could use my Point Manager program to insert a point at the insertion point of a selection of blocks, and then use the program again to insert a block reference at each of these points, before selecting and deleting the points. Quote
pBe Posted November 13, 2013 Posted November 13, 2013 A simple enough program to write X2 BTW: are the block(s) to be inserted includes attribute? Quote
CadFrank Posted November 13, 2013 Author Posted November 13, 2013 (edited) No they are dynamic block with no attributs. I would of used the replace block comme in express but i think since they are dynamic block's it doesn't work. I simply need to input a specified block at the same location as does in my drawing. the block's all have the same name but since it's dynamic well the "*U" it there and this makes it a little more complicated for me. Here ya go if ya need more information well I could send an autocad file. this is the code i've started : (defun c:mrt (/ ss1 item ctr) (vl-load-com) (setq ss1 (ssget "_x" '((8 . "-AL TETE")))) ;(setq ss1 (ssget "_X" '((2 . "TETE M-R")))) (setq ctr 0) (setvar "osmode" 0) (repeat (sslength ss1) (setq ent (entget(entlast))) (setq blk "VERIN M-R") (setq pts (cadr (assoc '10 ent))) (command "insert" blk pts 1 1 0 "") (setq ctr (1+ ctr)) ) (setvar "osmode" 1) (princ) ) Well with this i can insert the block's but not the the right points. What am I missing? Edited November 13, 2013 by CadFrank Quote
pBe Posted November 13, 2013 Posted November 13, 2013 First glance on why its not on the right points (command "insert" blk[b] "_non"[/b] pts 1 1 0 "") As for the Anonymous name (setq ss1 (ssget "_x" '((2 .[b] "TETE M-R,`*U*"[/b])))) Then iterate thru the selection with the use of vla-get-EffectiveName to filter the correct block name Quote
CadFrank Posted November 13, 2013 Author Posted November 13, 2013 Well it seem to me it only locates to the first entity. I dont know how to extract seperatly all the entity from the selection set even if the repeat is active. It only selects the last block Quote
pBe Posted November 13, 2013 Posted November 13, 2013 (edited) (Defun c:Demo (/ ss1 blk ent ctr) (if (and (setq blk (if (not (tblsearch "Block" "VERIN M-R")) (findfile "VERIN M-R.dwg") "VERIN M-R" ) ) (setq ctr 0 ss1 [color="blue"](ssget "_X" (list '(2 . "TETE M-R,`*U*")(cons 410 (getvar 'Ctab))))[/color] ) ) (repeat (sslength ss1) (if (eq (vla-get-effectivename (vlax-ename->vla-object (setq ent (ssname ss1 ctr))) ) "TETE M-R" ) (command "insert" blk "_non" (cdr (assoc '10 (entget ent))) 1 1 0 "" ) ) (setq ctr (1+ ctr)) ) ) (princ) ) EDIT: add "space" filter Edited November 13, 2013 by pBe Quote
CadFrank Posted November 13, 2013 Author Posted November 13, 2013 Oh come on...How can it be this easy... Thx alots.. it's exactly what i wanted. Quote
pBe Posted November 13, 2013 Posted November 13, 2013 Oh come on...How can it be this easy... Thx alots.. it's exactly what i wanted. Glad i could help BTW: on your posted code This doesn't make sense (setq ent (entget(entlast)));<---- Should be (Setq ent (entget (ssname ss1 ctr)));<-- where ctr is defined as 0 and this will give you the X value of assoc 10 (setq pts (cadr (assoc '10 ent)));<-- Should be: (setq pts ([b]cdr[/b] (assoc '10 ent))) Quote
CadFrank Posted November 13, 2013 Author Posted November 13, 2013 This doesn't make sense (setq ent (entget(entlast)));<---- Hehe I figured it made no sense when the routine inserted the block at the same place all the time. But, I need to study more this programming So thx alot for the information, really appreciated. 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.