Jump to content

Change Blocks Insertion point WITHOUT moving Existing Blocks


Recommended Posts

Posted

Hey Guys and gals,

 

I have a drawing with flow arrows that are blocks and I need to change the insertion point of the block without moving the existing blocks.

 

The reason is because they are in the right place but their insertion point is wrong. And everytime i move the insertion point it moves all the existing blocks...

Posted

not easy, in fact I haven't found a simple way of doing it.

 

It should be possible using LISP once you know the offset of your block geometry to its insertion point but I couldn't start to work that one out.

 

can you explode the blocks?

Posted

There is roughly 2000+ blocks so exploding and reinserting each block is not really an option

Posted

if they are all (most) inserted at 1:1 and orthagonally you could redefine the block and then using QSELECT move each rotational set by an known amount. This stops being simplae when you have a colection of scales and a multitude of rotations.

Posted

All scales are 1:1 but like u said the multitude of rotations is what makes it not so simple.

 

I found a forum where another guy posted the same question then he was forwarded to a german blog with a solution.....unfortunately i cant read german

Posted

this is the post (translated thanks chelsea1307) and their is a code .vlx txt file attached....which i dont know much about code

*how do i post the .vlx code file?

 

. .so new version for testing! I should again which have surveyed - > short report.

 

Tools function in such a way now in principle:

1. Selection of a block reference and choice of a new point of basis

2. The block reference is turned or scaled taken place (when desired) a conversion of the shift vector of point of basis.

3. Redefinition of the block through

- Shifting all elements of the block the turned shift vector of point of basis

(office 10 among other things set on (0,0,0,0,0,0))

4. Update of all references (when desired) by appropriate shift of their insert point

To application:

1. Memory as *.vlx

2. in the Autocad shop

3. Call with DT: BLOCK MOVE BASE POINT in the command line

or ^C^CDT: BLOCK MOVE BASE POINT on a button

Posted

i think you just open the .vlx copy the text and post it between here minus the extra space in the second set of brackets

[ /CODE]
Posted

This seems to work for me...it grabs the lower left bounding point, then redefine, then grab the left point again and move to previous stored point.

 

The block needs to be in your support path or add the path to the command call.

 

*no error checking and will bonk out if the block is on a locked layer.

 

(defun c:test (/ e n ss obj out rjp-bbleft)
 (defun rjp-bbleft (obj / ll ur)
   (vla-getboundingbox obj 'll 'ur)
   (vlax-safearray->list ll)
 )
 (setq n -1)
 (if (setq ss (ssget "_x" '((0 . "insert") (2 . "123"))))
   (progn (while (setq e (ssname ss (setq n (1+ n))))
        (setq obj (vlax-ename->vla-object e))
        (setq out (cons (list obj (rjp-bbleft obj)) out))
      )
      (command ".-INSERT" "123=123.dwg" '(0 0 0) (command))
      (foreach block out
        (vla-move (car block)
              (vlax-3d-point (rjp-bbleft (car block)))
              (vlax-3d-point (cadr block))
        )
      )
   )
 )
)

Posted

Hey RonJonP

 

So I copy and pasted your code into notepad, saved as test.lsp, In cad I went appload and loaded the lsp. When i type in test in the command prompt i get "nill" warning and nothing happens.

 

Im sure I must be doing something wrong?

 

Sorry for the inconvenience and thanks in advance for all the help!

Posted

Give this a try...the instructions are at the bottom.

(defun rjp-rbnomovey (bnames / e n ss obj out rjp-bbleft)
(vl-load-com)
 (defun rjp-bbleft (obj / ll ur)
   (vla-getboundingbox obj 'll 'ur)
   (vlax-safearray->list ll)
 )
 (setq n -1)
 (foreach name    bnames
   (if    (setq ss (ssget "_x" (list (cons 0 "insert") (cons 2 name))))
     (progn (while (setq e (ssname ss (setq n (1+ n))))
          (setq obj (vlax-ename->vla-object e))
          (setq out (cons (list obj (rjp-bbleft obj)) out))
        )
        (command ".-INSERT"
             (strcat name "=" name ".dwg")
             '(0 0 0)
             (command)
        )
        (foreach block out
          (vla-move (car block)
            (vlax-3d-point (rjp-bbleft (car block)))
            (vlax-3d-point (cadr block))
          )
        )
     )
   )
 )
 (princ)
)
;;Enter the names of the block names you are using in a list, redefined block drawing must be in search path
(rjp-rbnomovey '("blockname1" "blockname2" "blockname3"))

  • Thanks 1
Posted

This is the error I get

 

 

Command: appload

rjp-rbnomovey.lsp successfully loaded.

 

Command: Block san-arr references itself

*Invalid*

; error: Function cancelled

Posted

That error means you have a block defined in a drawing that has the same name as the drawing. The definition in the drawing has to be exploded.

 

Take a look at WBLOCK and see how it handles exporting blocks.

Posted

ronjonp you're a life saver!! The lisp is awesome

 

Much thanks for all the help guys

Posted
ronjonp you're a life saver!! The lisp is awesome

 

Much thanks for all the help guys

 

Glad we got it sorted out :D

Posted

Just to clarify: is this codes work for Acad 2002?

Posted
Just to clarify: is this codes work for Acad 2002?

 

It should work....but I do not have 2002 to test it on.

Posted

Looks like don't.

Command: (LOAD "C:/.../rjp.lsp")

Command: RJP-RBNOMOVEY

Unknown command "RJP-RBNOMOVEY". Press F1 for help.

 

 

Unless is other call command...

Posted
Looks like don't.

Command: (LOAD "C:/.../rjp.lsp")

Command: RJP-RBNOMOVEY

Unknown command "RJP-RBNOMOVEY". Press F1 for help.

 

 

Unless is other call command...

 

Read the bottom of the last post that contains the code...it will tell you how to use the command.

Posted

Never mind, need to restart AutoCAD to get it to work.

It is OK , sorry for trouble.

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