LISP to reinsert dyn blk / help to finalize needed

LISP to reinsert dyn blk / help to finalize needed

karpki
Advocate Advocate
1,155 Views
9 Replies
Message 1 of 10

LISP to reinsert dyn blk / help to finalize needed

karpki
Advocate
Advocate

Hi

The aim is to reinsert dynamic block to the same insertion point

I'm trying to code but insertion point issue doesn't work 

 

(defun c:DBRI (/ b obj bn ip)
  (vl-load-com)
  (setq
            b (entsel "\nSelect block: ")
            obj (vlax-ename->vla-object (car b))
            bn (vla-get-effectivename obj)
            ip (vla-get-InsertionPoint obj)
   )
  (Command "-INSERT" bn ip "" "" "")

  (vla-delete obj)
   (princ)

)

 

Could you pls help to finalize it

Thanks in advance!

K

 

 

0 Likes
Accepted solutions (1)
1,156 Views
9 Replies
Replies (9)
Message 2 of 10

hosneyalaa
Advisor
Advisor

 

TRY

(defun c: DBRI (/ b obj bn ip)
  (vl-load-com)
  (setq
            b (entsel "\ nSelect block:")
            obj (vlax-ename->vla-object (CAR b))
            ip (vlax-get obj 'insertionpoint)
   )
  (Command "-INSERT" bn ip "" "" "")

  (vla-delete obj)
   (princ)

)
0 Likes
Message 3 of 10

karpki
Advocate
Advocate

unfortunatelly it doesn't work

 

 

 

0 Likes
Message 4 of 10

hosneyalaa
Advisor
Advisor
(defun c:testDBRI (/ b obj bn ip)
  (vl-load-com)
  (setq
            b (entsel "\ nSelect block:")
            obj (vlax-ename->vla-object (CAR b))
            ip (vlax-get obj 'insertionpoint)
   )
  (Command "-INSERT" "bbbb" ip "" "" "")

  (vla-delete obj)
   (princ)

)

 

bb1.gif

0 Likes
Message 5 of 10

karpki
Advocate
Advocate

It works this way

 

(defun c:DBRI (/ b obj bn ip)
  (vl-load-com)
  (setq b (entsel "\nSelect block:"))
  (setq obj (vlax-ename->vla-object (car b)))
  (setq bn (vla-get-effectivename obj))
  (setq ip (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'InsertionPoint))))

  (Command "-INSERT" bn ip "" "" "")

  (vla-delete obj)
  (princ)
)

 

And now the question appears how to make so that OK button will be pressed automatically in the Enter Attributes window if I don't wanna change anything ?

karpki_0-1617561837504.png

 

0 Likes
Message 6 of 10

karpki
Advocate
Advocate

Test file

0 Likes
Message 7 of 10

karpki
Advocate
Advocate

Test file

0 Likes
Message 8 of 10

karpki
Advocate
Advocate

Thank you colleague!

I guess the main thing I have to say  it is sorry that I didn't post my own test file in the beginning.

Second thing: reinsert doesn't mean replace!

So the getting blockname (bn) is absolutely needed function for REinsertion

0 Likes
Message 9 of 10

hosneyalaa
Advisor
Advisor
Accepted solution
(defun c:testDBRI (/ b obj bn ip)
  (vl-load-com)
  (setq
            b (entsel "\ nSelect block:")
            obj (vlax-ename->vla-object (CAR b))
            ip (vlax-get obj 'insertionpoint)
   )
    (setvar "ATTDIA" 0)
  (Command "-INSERT" "ABH.6.41" ip "" "" "" "" "" "" "" "")
  (setvar "ATTDIA" 1)
  ;;(vla-delete obj)
   (princ)

)

 

 

 

BBB3.gif

0 Likes
Message 10 of 10

karpki
Advocate
Advocate
Thank you!
Yes, attdia change helps, so the final code is

(defun c:DBRI (/ b obj bn ip)
(vl-load-com)
(setq b (entsel "\nSelect block:"))
(setq obj (vlax-ename->vla-object (car b)))
(setq bn (vla-get-effectivename obj))
(setq ip (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'InsertionPoint))))
(setvar "ATTDIA" 0)
(Command "-INSERT" bn ip "" "" "" "" "" "" "" "")
(setvar "ATTDIA" 1)
(vla-delete obj)
(princ)
)