Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing the insertion point of a block

5 REPLIES 5
Reply
Message 1 of 6
thavasi1982
5015 Views, 5 Replies

Changing the insertion point of a block

Hi all,

            I have insert blocks in my dwg. It is the circle. While creating the block, i was just pick the point into the circle not exactly at the centre.

 

          Now i want change the insertion point of the block at centre of the circle without moving the objects from the dwg.

Beacuse i had use block editor to change the insertion point. But after changing, all blocks were moved from the original position.

 

Thanks

 

5 REPLIES 5
Message 2 of 6
stevor
in reply to: thavasi1982

What is usally done: Move them ,all the INSERTs of that changed BLOCK, back to their original location. Keep track of the displacement created by the change in the insertion point in the BLOCK, and use it to move a selection set of 'them;' or, to modify each INSERT's data by other methods, which someone will likely detail soon.
S
Message 3 of 6
pbejse
in reply to: stevor


@stevor wrote:
What is usally done: Move them ,all the INSERTs of that changed BLOCK, back to their original location. Keep track of the displacement created by the change in the insertion point in the BLOCK, and use it to move a selection set of 'them;' or, to modify each INSERT's data by other methods, which someone will likely detail soon.

Thats right. I worte a code for the OP,  but i'm having trouble with rotated blocks and those with attributes.

 

(defun c:ChangeIns  (/ adoc* doc* BlkObjct npt mpt or_pt)
  (setq	adoc* (vlax-get-acad-object)
	doc*  (vla-get-activedocument adoc*))
  (if (setq BlkObjct (car (entsel "\nSelect Block:")))
    (cond
      ((eq (cdr (assoc 0 (setq ent_b (entget BlkObjct)))) "INSERT")
       (setq npt (getpoint "\nSelect New Point:"))
       (ssget "_X" (list (setq bn (assoc 2 ent_b))))
       (vlax-for bnm  (vla-get-blocks doc*)
	 (if (eq (vla-get-name bnm) (cdr bn))
	   (vlax-for nest_obj  bnm
	     (vla-move nest_obj
		       (vlax-3d-point '(0.0 0.0 0.0))
		       (vlax-3d-point
			 (setq mpt
				(mapcar '- (cdr (assoc 10 ent_b)) npt)))
		       )
	     )
	   )
	 )
       (vlax-for mo_bk	(vla-get-activeselectionset doc*)
	 (vla-move
	   mo_bk
	   (vlax-3d-point
	     (mapcar
	       '+
	       (vlax-safearray->list
		 (variant-value
		   (setq or_pt (vla-get-insertionpoint mo_bk))))
	       mpt))
	   or_pt)
	 )
       )
      )
    )
  )

 

Change origin perhaps ? (vla-put-origin.....) not sure though.  

Ideas anyone?

 

 

Message 4 of 6
stevor
in reply to: thavasi1982

While the Vlisp methods are shorter, more elegant, and more comprehensive, they do not reveal all the steps involved [otherwise they would not be shorter.] .... If that method does not suffice, then you could try the older method of exploding and INSERT into the entities that the BLOCk represents, and go from there. There are many examples around..... I would post some, but have not yet discovered why my posts, via 'Reply,' no longer provides line-feeds/carrige-returns, nor code windows.
S
Message 5 of 6
Anonymous
in reply to: thavasi1982

Well, just would like to share a lisp for as what you need..I also use to get the lisp from here in one of the threads..hope this help you..Thanks to the author who said this lisp out previously.

Message 6 of 6
rambojazdude
in reply to: Anonymous

OMG you are a life saver. Thanks dude!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost