LISP for redefining blocks insertion point in multiple DWG files

LISP for redefining blocks insertion point in multiple DWG files

ISnyder83RVP
Participant Participant
1,189 Views
3 Replies
Message 1 of 4

LISP for redefining blocks insertion point in multiple DWG files

ISnyder83RVP
Participant
Participant

I am working with old AutoCAD files that contain older blocks, which have since been modified to have different insertion points.  These blocks are included in a new Dynamic block which needs the modified blocks new insertion point. I have gone through (1) drawing (DWG) and used Lee Mac Programming's "Change Block Base Point" (Excellent program!) to redefine the insertion points of multiple blocks that have already been inserted.

The problem I have is, I need this done on many different drawing (DWG) files.  With some of the blocks being oddly shaped and needing a specific insertion points, it would be hard to get the exact insertion point in every drawing. It would be nice to update the blocks in (1) drawing and then automatically redefine the blocks in all the other drawings without moving the block location.

 

Example:

Say I have a block called 'A' in drawing '1' and this block is also in a dynamic block called 'DynamicA'.  Now say drawing '2' has block 'A' already inserted, but it has a different insertion point and I need to add 'DynamicA' to this drawing.  Without updating the insertion point of 'A' and inserting 'DynamicA', 'DynamicA' would now be incorrect.    

 

Is it possible to write a LISP that would move the insertion points within the blocks of multiple drawings without moving the actual block?  Fixing the insertion points in a couple drawings isn't bad, but I have quite a few drawings that need the insertion points moved, plus it would be hard to remember each blocks insertion point when some are in odd locations.

 

I hope this makes sense!

0 Likes
1,190 Views
3 Replies
Replies (3)
Message 2 of 4

Sea-Haven
Mentor
Mentor

The basepoint and block location are two separate points so if you move the base point you will need to move the block so it stays at the same spot. This would need a brg & dist or X & Y offset difference. Then you could move every block in a dwg back to where it was. You can pass these values to a lisp as part of the script.

0 Likes
Message 3 of 4

ISnyder83RVP
Participant
Participant

@Sea-Haven wrote:

The basepoint and block location are two separate points so if you move the base point you will need to move the block so it stays at the same spot. This would need a brg & dist or X & Y offset difference. Then you could move every block in a dwg back to where it was. You can pass these values to a lisp as part of the script.


I am basically looking for a program like Lee Mac Programming's "Change Block Base Point" with the "CBPR: Change Base Point retain Reference position" capabilities, but would be able to update the same block in multiple drawings (DWGs) automatically.  I need the block components to stay where they are, but the insertion point needs to be located within the blocks components rather than off to the side. 

CBPR: Change Base Point retain Reference position

0 Likes
Message 4 of 4

Sea-Haven
Mentor
Mentor

It is feasible to do an automatic update using lee's code if you look at these  lines

 

(progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect Block: ")))
(if (and (= 'ename (type ent)) (setq nbp (getpoint "\nSpecify New Base Point: ")))
 
You would need to redo the entsel as a find a block by name use (ssname ss 0) get insertion point.
The getpoint would be a point from the insertion point of block, say as a X Y difference or angle dist.
 
The (defun LM:changeblockbasepoint ( flg 
(defun LM:changeblockbasepoint ( flg blkname x y
 
So in a script (load "ChangeBlockBasePointV1-5.lsp")(LM:changeblockbasepoint t blkname x y)
 
 
 
 
0 Likes