LISP to reinsert dyn blk / help to finalize needed

LISP to reinsert dyn blk / help to finalize needed

karpki
Advocate Advocate
1,165件の閲覧回数
9件の返信
メッセージ1/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 件のいいね
解決済み
1,166件の閲覧回数
9件の返信
返信 (9)
メッセージ2/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 件のいいね
メッセージ3/10

karpki
Advocate
Advocate

unfortunatelly it doesn't work

 

 

 

0 件のいいね
メッセージ4/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 件のいいね
メッセージ5/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 件のいいね
メッセージ6/10

karpki
Advocate
Advocate

Test file

0 件のいいね
メッセージ7/10

karpki
Advocate
Advocate

Test file

0 件のいいね
メッセージ8/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 件のいいね
メッセージ9/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)
   )
    (setvar "ATTDIA" 0)
  (Command "-INSERT" "ABH.6.41" ip "" "" "" "" "" "" "" "")
  (setvar "ATTDIA" 1)
  ;;(vla-delete obj)
   (princ)

)

 

 

 

BBB3.gif

0 件のいいね
メッセージ10/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)
)