System var or routine for (promptless) redefining blocks?

Topics relating to AutoLisp and SDS.

Moderators: CMS Inc, avaernes

Post Reply
AJS
Contributor
Posts: 10
Joined: Tue Feb 10, 2009 11:54 am

System var or routine for (promptless) redefining blocks?

Post by AJS » Wed Feb 25, 2009 2:12 pm

I have a lisp that automatically inserts a block--sometimes multiple times.

When the block is inserted twice or more, the user is prompted whether or not to re-define the block.

Is there a system variable that I can set up to automatically re-define the block without a prompt?

I read through the variables but I couldn't find one that seemed to accomplish this but it wouldn't be the first time I've ovelooked what would have worked.

Thanks

AJS
JCAMPOS

Post by JCAMPOS » Thu Feb 26, 2009 4:13 am

AJS,

This occurs probably because you are giving the full path at the insertion command.
To workaround this problem you can make an error routine. Please try the following:

Code: Select all

(defun C:InsertMyBlock ( / temperr dwgFILE dwgNAME insertionPt Xscale Yscale rotAngle )

;; Define an error trap routine
(setq temperr *error*)
(setq *error* InsertMyBlockErrorTrap)

;; Set the block properties
(setq dwgFILE "C:\\MyBlock.dwg")
(setq dwgNAME "MyBlock")
(setq insertionPt (list 0.0 0.0 0.0))

;; Set the insertion defaults:
(setq Xscale 1.0)
(setq Yscale 1.0)
(setq rotAng 0.0)

;; Try to insert the block by giving only its name - dwgNAME - (and, of course, all of the insertion properties).
;; If the block hasn't been inserted yet, then the error routine is executed
(command "_.INSERT" dwgNAME insertionPt Xscale Yscale rotAng)

;; Exists quietly
(setq *error* temperr)
(princ)
)


;; Error trap routine:
;; This routine will be fired as soon as an error occurs in the main routine
;; It will insert the block if the block is not defined in the drawing.
(defun InsertMyBlockErrorTrap ( errmsg / )
;; Insert the block by giving the full path name - dwgFILE:
(command "_.INSERT" dwgFILE insertionPt Xscale Yscale rotAng)
)
Regards,
JCAMPOS
efernal
Valued Contributor
Posts: 28
Joined: Thu Jul 05, 2007 6:42 pm
Contact:

Post by efernal » Mon Mar 02, 2009 12:01 pm

I use another way...

(defun c:test (/ block)
(if (null (tblsearch "block" "myblock"))
(setq block "c:\\my_folder\\myblock.dwg")
(setq block "myblock")
)
(while (setq p1 (getpoint "\n-> Insertion point : "))
(command "_.INSERT" myblock p1 1. 1. 0. [attributes values])
)
(princ)
)

e.fernal
http://www.gr-acad.com.br
efernal
Valued Contributor
Posts: 28
Joined: Thu Jul 05, 2007 6:42 pm
Contact:

Post by efernal » Mon Mar 02, 2009 12:04 pm

oops, change

(command "_.INSERT" myblock p1 1. 1. 0. [attributes values])

for

(command "_.INSERT" block p1 1. 1. 0. [attributes values])


e.fernal
AJS
Contributor
Posts: 10
Joined: Tue Feb 10, 2009 11:54 am

Post by AJS » Fri Mar 06, 2009 9:50 pm

I apologize for not responding. I was away from my computer for a week.

I'm going to take a look at these over the weekend.

Thanks for the help.


AJS
Post Reply