Jump to content

Recommended Posts

Posted

I wrote a simple list routine back in 1995 that was supposed to put an integer in a box (or circle) and increment the value the next time you picked a new point. I have a block called memnum that is a rectangle with some text inside and another block that is a circle with some text inside called jn.

 

When I load the lisp it asks me my start number and a scale factor as it should, but the mem code just has "XXXX" inside the box and does not increment the value. It hasbeen years since I have run this code and I don't see why it quit working. Can some of you smart LISP folks see why it is not incrementing my value? The MEM code puts a number in the box and the JOI code puts a number in a circle.

 

 
;; This lisp routine was written by George T. Watson on 5-10-95
;; This routine will insert an incremented number in a box
(defun c:mem (/ pt1 val scale )
(setq val (getint "\nEnter member number to start with   "))
(setq scale (getint "\nEnter scale factor   "))
(while val
(setq pt1 (getpoint "\nPick next Point"))
       (command "insert" "memnum" pt1  scale "" "" val)
       (setq val (1+ val))
)  ; end of while loop
)  ; end of defun
;; This routine will insert an incremented number in a circle
(defun c:joi (/ pt1 val scale )
(setq val (getint "\nEnter Joint number to start with   "))
(setq scale (getint "\nEnter scale factor   "))
(while val
(setq pt1 (getpoint "\nPick next Point"))
       (command "insert" "jn" pt1  scale "" "" val)
       (setq val (1+ val))
) ; end of while loop
) ; end of defun

Posted

Hi George,

 

Give this a shot mate:

 

(defun c:mem ( / *error* block old pt scale val var )

 (setq block "memnum")  ;; Block to be Inserted

 (defun *error* ( msg )
   (if old (mapcar 'setvar var old))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )

 (setq var '("CMDECHO" "ATTREQ") old (mapcar 'getvar var))
 (mapcar 'setvar var '(0 1))

 (if
   (or
     (tblsearch "BLOCK" block)
     (findfile (strcat block ".dwg"))
   )
   (if
     (and (setq val (getint "\nEnter member number to start with: "))
       (progn
         (initget 6)
         (setq scale (getint "\nEnter scale factor: "))
       )
     )
     (while (setq pt (getpoint "\nPick next Point: "))
       (command "_.-insert" block "_S" scale "_non" pt "" (itoa val))
       (setq val (1+ val))
     )
   )
   (princ (strcat "\n--> " block ".dwg not Found."))
 )
 (mapcar 'setvar var old)
 (princ)
)

 

I've added some error trapping to your routine to check for valid input and existence of the block to be inserted.

Posted

Set your attreq system variable to 1.

Posted

I'm no lisp guru, but on my system it gives an error related to not being able to find "memnum.dwg". If you have that block stored somewhere, you need to either add its location to the search path or move the drawing to one of them in your search path list.

Posted

Actually this would probably be better to combine the two routines:

 

(defun c:mem nil (InsertBlock "memnum" "\nEnter Member Number to start with: "))
(defun c:joi nil (InsertBlock "jn"     "\nEnter Joint Number to start with: "))

(defun InsertBlock ( block msg / *error* old pt scale val var )

 (defun *error* ( msg )
   (if old (mapcar 'setvar var old))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )

 (setq var '("CMDECHO" "ATTREQ") old (mapcar 'getvar var))
 (mapcar 'setvar var '(0 1))

 (if
   (or
     (tblsearch "BLOCK" block)
     (findfile (strcat block ".dwg"))
   )
   (if
     (and (setq val (getint msg))
       (progn
         (initget 6) (setq scale (getint "\nEnter scale factor: "))
       )
     )
     (while (setq pt (getpoint "\nPick next Point: "))
       (command "_.-insert" block "_S" scale "_non" pt "" (itoa val))
       (setq val (1+ val))
     )
   )
   (princ (strcat "\n--> " block ".dwg not Found."))
 )
 (mapcar 'setvar var old)
 (princ)
)

Posted

Lee Mac;

Thanks, that worked.

 

Alanjt;

Setting the system variable attreq to 1 (it was 0) worked with my original code.

 

Jack;

Yes, the little drawing memnum is just a rectangle with the text inside and it is my search path.

 

Thanks all for the help. Back in 1995, I knew what I was attempting to do, but the years in between then and now have blurred the memory.

Posted
Lee Mac;

Thanks, that worked.

 

Alanjt;

Setting the system variable attreq to 1 (it was 0) worked with my original code.

 

Jack;

Yes, the little drawing memnum is just a rectangle with the text inside and it is my search path.

 

Thanks all for the help. Back in 1995, I knew what I was attempting to do, but the years in between then and now have blurred the memory.

 

Lee and some of these other folks have forgotten more than I ever knew about writing lisp. I used to could take one that was close to what I wanted to do and massage it till it did what I wanted but lately haven't even had that much success.

 

You wanna draw something, I can be all up in that. You wanna write a program to draw something, I'll be standing over on the side going "ooooo....pretty!"

Posted
Lee Mac;

Thanks, that worked.

 

Good to hear g****son :)

 

(lol at your name being censored)

Posted
Good to hear g****son :)

 

(lol at your name being censored)

t.wat are you talking about?

Posted
Alanjt;

Setting the system variable attreq to 1 (it was 0) worked with my original code.

Yeah, I figured as much. Nothing wrong with what Lee gave you, but you should understand what was actually going wrong.

Posted
Yeah, I figured as much. Nothing wrong with what Lee gave you, but you should understand what was actually going wrong.

 

I looked up attreq and it has something to do with blocks and prompts that I don't quite understand.

 

1

Turns on prompts or a dialog box for attribute values, as specified by ATTDIA

 

 

As you can tell, I am no programmer of LISP. I used to do some FORTRAN and once learned ICAD which was an AI language based on lisp. I am an Engineer that plays with ACAD to produce drawings.

 

I would guess that attreq being off caused the attributed text to be inserted and not the value I wanted to be put in the box or circle.

 

Thanks for all the help. I will probably be back to ask more dumb lisp questions, so be patient with an old FORTRAN programmer.

Posted
Actually this would probably be better to combine the two routines:

 

(defun c:mem nil (InsertBlock "memnum" "\nEnter Member Number to start with: "))
(defun c:joi nil (InsertBlock "jn" "\nEnter Joint Number to start with: "))

(defun InsertBlock ( block msg / *error* old pt scale val var )

(defun *error* ( msg )
(if old (mapcar 'setvar var old))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ)
)

(setq var '("CMDECHO" "ATTREQ") old (mapcar 'getvar var))
(mapcar 'setvar var '(0 1))

(if
(or
(tblsearch "BLOCK" block)
(findfile (strcat block ".dwg"))
)
(if
(and (setq val (getint msg))
(progn
(initget 6) (setq scale (getint "\nEnter scale factor: "))
)
)
(while (setq pt (getpoint "\nPick next Point: "))
(command "_.-insert" block "_S" scale "_non" pt "" (itoa val))
(setq val (1+ val))
)
)
(princ (strcat "\n--> " block ".dwg not Found."))
)
(mapcar 'setvar var old)
(princ)
)

 

I was thinking that it would be nice to combine an alpha character in front of the integer but I'm not sure how to apply strcat.

Posted
I was thinking that it would be nice to combine an alpha character in front of the integer but I'm not sure how to apply strcat.

 

Try something like this:

 

(defun c:mem nil (InsertBlock "memnum" "\nEnter Member Number to start with: "))
(defun c:joi nil (InsertBlock "jn"     "\nEnter Joint Number to start with: "))

(defun InsertBlock ( block msg / *error* old pre pt scale val var )

 (defun *error* ( msg )
   (if old (mapcar 'setvar var old))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )

 (setq var '("CMDECHO" "ATTREQ") old (mapcar 'getvar var))
 (mapcar 'setvar var '(0 1))

 (if
   (or
     (tblsearch "BLOCK" block)
     (findfile (strcat block ".dwg"))
   )
   (if
     (and
       (setq pre (getstring t "\nSpecify Prefix <None>: "))
       (setq val (getint msg))
       (progn
         (initget 6) (setq scale (getint "\nEnter scale factor: "))
       )
     )
     (while (setq pt (getpoint "\nPick next Point: "))
       (command "_.-insert" block "_S" scale "_non" pt "" (strcat pre (itoa val)))
       (setq val (1+ val))
     )
   )
   (princ (strcat "\n--> " block ".dwg not Found."))
 )
 (mapcar 'setvar var old)
 (princ)
)

 

BTW, with regards to ATTREQ: If set to 0, you will not be prompted to 'Enter Attributes' when inserting a block, otherwise, if set to 1, the prompt will appear.

Posted

Many thanks, that worked perfectly. I'll stop begging for Lisp help and try to learn some on my own. :D

Posted

Let me know if you ever need any lattice Transmission Towers or tapered tubular poles designed (my area of expertise) and I'll be glad to help.

 

These numbers in boxes are used to define a member size on a schematic drawing. It will tell the structure detailer the angle size, the number of bolts, and number of holes out as well as which leg is bolted, in case you had a burning desire to know how this lisp code is used.

 

I originally created it back last millinium to annotate a drawing. The circles with numbers designated the joint number and the boxes defined the member number when I was doing my structural model of a 3 dimensional truss. The ACAD drawing was used to document the model to see what member went where.

Posted
Let me know if you ever need any lattice Transmission Towers or tapered tubular poles designed (my area of expertise) and I'll be glad to help.

 

Thanks, I'll keep you in mind if I ever have that need :P

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...