Author Topic: Insert titleblock without defining attribute values  (Read 3284 times)

0 Members and 1 Guest are viewing this topic.

hyposmurf

  • Guest
Insert titleblock without defining attribute values
« 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)
)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Insert titleblock without defining attribute values
« Reply #1 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)
)
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Insert titleblock without defining attribute values
« Reply #2 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)
)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Insert titleblock without defining attribute values
« Reply #3 on: March 21, 2006, 08:18:04 AM »
I thought about that, but figured he wanted to do scale himself
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

hyposmurf

  • Guest
Re: Insert titleblock without defining attribute values
« Reply #4 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.

hyposmurf

  • Guest
Re: Insert titleblock without defining attribute values
« Reply #5 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. :-)

kpblc

  • Bull Frog
  • Posts: 396
Re: Insert titleblock without defining attribute values
« Reply #6 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.
Sorry for my English.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Insert titleblock without defining attribute values
« Reply #7 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)
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

sinc

  • Guest
Re: Insert titleblock without defining attribute values
« Reply #8 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.

hyposmurf

  • Guest
Re: Insert titleblock without defining attribute values
« Reply #9 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. :-)