TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: hyposmurf on March 21, 2006, 08:04:59 AM

Title: Insert titleblock without defining attribute values
Post by: hyposmurf on March 21, 2006, 08:04:59 AM
Ive come up some lisp tp insert my titleblocks.All works fine but I dont want to define the attributes just a straight insert at rotation 0 scale 1 etc.How do I go about this?Like adding a number of returns as you would do if inserted manually or to a macro.

;;;;;;;;A0TBLOCK.lsp;;;;
;;Created by Me;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:A0()
(command "-insert" "A0TITLE")
(princ)
)
Title: Re: Insert titleblock without defining attribute values
Post by: David Hall on March 21, 2006, 08:06:39 AM
(setvar "attreq" 0)

be sure to reset to 1 later

(defun c:A0()
(setq atq (getvar "attreq"))
(setvar "attreq" 0)
(command "-insert" "A0TITLE")
(setvar "attreq" atq)
(princ)
)
Title: Re: Insert titleblock without defining attribute values
Post by: V-Man on March 21, 2006, 08:16:39 AM

Quote
(defun c:A0()
(setq atq (getvar "attreq"))
(setvar "attreq" 0)
(command "-insert" "A0TITLE")
(setvar "attreq" atq)
(princ)
)

Maybe this

(defun c:A0()
(setq atq (getvar "attreq"))
(setvar "attreq" 0)
(command "-insert" "A0TITLE" "0,0" "" "" "")   <-----Changed this
(setvar "attreq" atq)
(princ)
)
Title: Re: Insert titleblock without defining attribute values
Post by: David Hall on March 21, 2006, 08:18:04 AM
I thought about that, but figured he wanted to do scale himself
Title: Re: Insert titleblock without defining attribute values
Post by: hyposmurf on March 21, 2006, 08:21:14 AM
Tnks to both of you,I dont need to scale my titleblocks, but having both options there now gives me to work with .Oh by the way and here is what I came up with just for your amusement:
;;;;;;;;A0TBLOCK.lsp;;;;;;;;;;
;;Created by Me;;;
;;;;;;;;;;;;;;;;;;;;;;;;
(setvar "attreq" 0)
(defun c:A0()
(command "-insert" "A0TITLE")
(setq 1 (getvar "attreq"))
(princ)
)

It doenst wor I know my vain attempt and dont have anything to refrence with at work.
Title: Re: Insert titleblock without defining attribute values
Post by: hyposmurf on March 21, 2006, 08:25:03 AM
So "" works as a return,some of the basics arent to far off macros that I can get my head around. :-)
Title: Re: Insert titleblock without defining attribute values
Post by: kpblc on March 21, 2006, 08:33:26 AM
Code: [Select]
(defun c:a0ins (/ adoc _attreq_ _cmdecho_ *error*)
  (defun *error* (msg)
    (if _attreq_
      (setvar "attreq" _attreq_)
      ) ;_ end of if
    (if _cmdecho_
      (setvar "cmdecho" _cmdecho_)
      ) ;_ end of if
    (vla-endundomark adoc)
    (princ msg)
    (princ)
    ) ;_ end of defun
  (vl-load-com)
  (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark adoc)
  (if (tblobjname "block" "a0title")
    (progn
      (setq _attreq_  (getvar "attreq")
    _cmdecho_ (getvar "cmdecho")
    ) ;_ end of setq
      (mapcar 'setvar '("attreq" "cmdecho") '(0 0))
      (command "_.-insert" "a0title")
      (while (/= (logand (getvar "cmdactive") 31) 0)
(command pause)
) ;_ end of while
      (mapcar 'setvar
      '("attreq" "cmdecho")
      (list _attreq_ _cmdecho_)
      ) ;_ end of mapcar
      ) ;_ end of progn
    (alert "There is no block \"a0title\" defined in current drawing!")
    ) ;_ end of if
  (vla-endundomark adoc)
  ) ;_ end of defun
I didn't test this code 'cos i havn't enoght time.
Title: Re: Insert titleblock without defining attribute values
Post by: David Hall on March 21, 2006, 08:36:23 AM
Tnks to both of you,I dont need to scale my titleblocks, but having both options there now gives me to work with .Oh by the way and here is what I came up with just for your amusement:
;;;;;;;;A0TBLOCK.lsp;;;;;;;;;;
;;Created by Me;;;
;;;;;;;;;;;;;;;;;;;;;;;;
(setvar "attreq" 0)
(defun c:A0()
(command "-insert" "A0TITLE")
(setq 1 (getvar "attreq"))   <------  This line is not doing what you think it is
(princ)
)

It doenst wor I know my vain attempt and dont have anything to refrence with at work.

You need to fix the above line to
(setvar "attreq" 1)
Title: Re: Insert titleblock without defining attribute values
Post by: sinc on March 21, 2006, 12:39:29 PM
What version of Autocad are you using?

Things like Palettes and Sheet Set Manager work well for this task, if you have them available.  I prefer using built-in stuff when it exists, since having too many Lisp routines causes its own problems.
Title: Re: Insert titleblock without defining attribute values
Post by: hyposmurf on March 21, 2006, 05:37:31 PM
I like using my palettes and menu butons but, I have a problem with my palettes.They load full ADT sometimes when right clicking them which I dont need as vanilla CAD can only be set to save as 2000(unlike ADT) and I've ended up with tons of buttons,just like the idea of pressing two buttons on my keyboard and titleblocks are there.Plus something like this which is a simple task you  8-) blokes are teaching me how to do it in LISP and I can manage to keep up. :-)