Jump to content

Block insertion into a basepoint of another


Recommended Posts

Posted

Hi, does anyone know of a routine to insert multiple block's in the basepoint of other blocks.

Posted

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.

Posted
A simple enough program to write

 

X2

 

BTW: are the block(s) to be inserted includes attribute?

Posted (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 by CadFrank
Posted

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

Posted

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

Posted (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 by pBe
Posted

Oh come on...How can it be this easy... :P

 

Thx alots.. it's exactly what i wanted.

Posted
Oh come on...How can it be this easy... :P

 

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)))

Posted

 

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 :D

 

So thx alot for the information, really appreciated.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...