Jump to content

IWS.lsp by Peter Jamtgaard won't run for me.


Recommended Posts

Posted

I have what appears to be a very nice, useful lisp program written by Peter Jamtgaard (attached). I picked it up a while ago, apparently, because I cannot remember where I got it, even. I can't get the program to run completely on my computer and AutoCAD settings, however. Could someone else give it a try and see what results they get? (It allows the user to select a W shape structural steel member, and then is supposed to insert the shape into the drawing). If you find that you cannot get it to run, either, could someone perhaps make suggested changes that might get it to run?

 

If Peter should happen to spot my message, could you please confirm that you have no objections to my using the program if we can get it to work on my computer? (Particularly since I cannot remember where I got it from.)

 

I couldn't get the lsp, dcl, and txt files necessary for the program to upload for some reason, so I added them with CODE tags within my post. I see that line wrapping did a number on some of it, but I don't think that should affect the program. (I hope ???)

 

Thank you.

 

Windows 7 Pro

AutoCAD 2010

 

IWS.LSP AS FOLLOWS:

 


; Written By: Peter Jamtgaard
; This program will create wshape (Beams) 
using a dialog box or command line entry.
; The cmddia system variable set to 
0 will allow the command line entry.
; The program uses parametric data in 
the iws.txt file to create the wshape as a 
; block with the appropriate 
name. It also uses a dcl file iws.dcl to control the dialog
; box entry 
method.


(defun C:IWS (/ WSNLIST)
(WSHP)
(if (= (getvar "cmddia") 
0)
 (progn
  (while (not (member (setq BLKNAM (getstring 
"\nEnter wshape name: ")) (mapcar 'car WSNLIST)))
   (princ 
"\nUnrecognized wshape name please try again: ")

)
  (setq WSHPNUM (- (length (member BLKNAM (reverse (mapcar 'car 
WSNLIST)))) 1))
 )
 (progn

(DDWSHP)
  (setq BLKNAM (nth WSHPNUM (mapcar 'car 
WSNLIST)))
 )
)


(if (not (tblsearch "BLOCK" BNAMES))
 (MakeWSBlk (nth WSHPNUM 
WSNLIST))
)
(command "insert" BLKNAM pause "1" "1" 
pause)
)


; Import parametric information from iws.txt text file into a list.


(defun WSHP (/ WSHPDATA WNAME DEPTHR TWR WIDTHR TFR KR)
(setq z 
(open (findfile "IWS.TXT") "r"))
(if (not WSNLIST)

(progn
  (setq B 0 C -1)
  (while (setq BLKNAM 
(read-line z))        

(setq DEPTHR   (atof (read-line 
z))

TWR      (atof (read-line 
z))
         WIDTHR   
(atof (read-line z))

TFR      (atof (read-line 
z))

KR       (atof (read-line 
z))
         WSHPDATA (list 
BLKNAM DEPTHR TWR WIDTHR TFR 
KR)
         WSNLIST  
(cons WSHPDATA WSNLIST)
   )

)
  (setq WSNLIST (reverse WSNLIST))

)
)
(close z)
)


; IWS dialog box wshape selection box.


(defun DDWSHP ()
(if (= WSHPNUM nil)(setq WSHPNUM 1))
(setq 
id (load_dialog "iws.dcl"))
(new_dialog "pickw" 
id)
(start_list "wshapes")
 (mapcar 'add_list (mapcar 'car 
WSNLIST))
 (end_list)
(set_tile "wshapes" (itoa 
WSHPNUM))
(action_tile "wshapes" "(progn (setq WSHPNUM (atoi $value)) 
(princ WSHPNUM))")
(if (= (start_dialog) 1)
 WSHPNUM

nil
)
)


(defun MakeWSblk (WSHPDATA / BLKNAM DEPTHR TWR WIDTHR TFR KR)
(setq 
BLKNAM (nth 0 WSHPDATA)
      DEPTHR (nth 1 
WSHPDATA)
      TWR    (nth 2 
WSHPDATA)
      WIDTHR (nth 3 
WSHPDATA)
      TFR    (nth 4 
WSHPDATA)
      KR     
(nth 5 WSHPDATA)
)


(entmake
 (list '(0 . "BLOCK")
  (cons 2  
BLKNAM)
 '(70 . 0)
  (cons '10 '(0.0 0.0 0.0))

)
)
(entmake
 (list 
  '(0 . 
"LWPOLYLINE")
  '(5 . "AD")
  '(100 . 
"AcDbEntity")
  '(67 . 0)
  '(410 . 
"Model")
  '(8 . "0")
  '(100 . 
"AcDbPolyline")
  '(90 . 16)
  '(70 . 
1)
  '(43 . 0.0)
  '(38 . 0.0)
  '(39 
. 0.0)
  (list 10 (* -1 (/ WIDTHR 2.0)) (* -1 (/ DEPTHR 
2.0)))
  '(40 . 0.0)
  '(41 . 0.0)

'(42 . 0.0)
  (list 10 (/ WIDTHR 2.0) (* -1 (/ DEPTHR 
2.0)))
  '(40 . 0.0)
  '(41 . 0.0)

'(42 . 0.0)
  (list 10 (/ WIDTHR 2.0) (+ TFR (* -1 (/ DEPTHR 
2.0))))
  '(40 . 0.0)
  '(41 . 0.0)

'(42 . 0.0)
  (list 10 (+ (/ TWR 2.0) KR) (+ TFR (* -1 (/ DEPTHR 
2.0))))
  '(40 . 0.0)
  '(41 . 0.0)

'(42 . -0.414214)
  (list 10 (/ TWR 2.0) (+ KR TFR (* -1 (/ DEPTHR 
2.0))))
  '(40 . 0.0)
  '(41 . 0.0)

'(42 . 0.0)
  (list 10 (/ TWR 2.0) (- (/ DEPTHR 2.0) KR 
TFR))
  '(40 . 0.0)
  '(41 . 0.0)

'(42 . -0.414214)
  (list 10 (+ (/ TWR 2.0) KR) (- (/ DEPTHR 2.0) 
TFR ))
  '(40 . 0.0)
  '(41 . 0.0)

'(42 . 0.0)
  (list 10 (/ WIDTHR 2.0) (- (/ DEPTHR 2.0) TFR 
))
  '(40 . 0.0)
  '(41 . 0.0)
  '(42 
. 0.0)
  (list 10 (/ WIDTHR 2.0) (/ DEPTHR 2.0))

'(40 . 0.0)
  '(41 . 0.0)
  '(42 . 
0.0)
  (list 10 (/ WIDTHR -2.0) (/ DEPTHR 2.0))

'(40 . 0.0)
  '(41 . 0.0)
  '(42 . 
0.0)
  (list 10 (/ WIDTHR -2.0) (- (/ DEPTHR 2.0) TFR 
))
  '(40 . 0.0)
  '(41 . 0.0)
  '(42 
. 0.0)
  (list 10 (* -1 (+ (/ TWR 2.0) KR)) (- (/ DEPTHR 2.0) TFR 
))
  '(40 . 0.0)
  '(41 . 0.0)
  '(42 
. -0.414214)
  (list 10 (* -1 (/ TWR 2.0)) (- (/ DEPTHR 2.0) KR 
TFR))
  '(40 . 0.0)
  '(41 . 0.0)

'(42 . 0.0)
  (list 10 (* -1 (/ TWR 2.0)) (* -1 (- (/ DEPTHR 2.0) 
KR TFR)))  
  '(40 . 0.0)
  '(41 . 
0.0)
  '(42 . -0.414214)
  (list 10 (* -1 (+ KR (/ 
TWR 2.0))) (+ TFR (* -1 (/ DEPTHR 2.0))))
  '(40 . 
0.0)
  '(41 . 0.0)
  '(42 . 0.0)

(list 10 (* -1 (/ WIDTHR 2.0)) (+ TFR (* -1 (/ DEPTHR 2.0))))

'(40 . 0.0)
  '(41 . 0.0)
  '(42 . 
0.0)
  '(210 0.0 0.0 1.0)
 ) 

)
(entmake '((0 . "endblk")))
)

 

IWS.DCL AS FOLLOWS:


pickw : dialog {
 label="Insert W Shapes";
 :list_box { 
key             = 
"wshapes"; 


height          = 
10;

width           = 5; 


multiple_select = 
true;

allow_accept    = 
true;

}
 ok_cancel;
}

 

 

IWS.TXT AS FOLLOWS (ABBREVIATED)

 

 


W4X13
4.160
0.280
4.060
0.345
0.687
W5X16
4.68
0.240
5.000
0.360
0.750
W5X19
5.15
0.270
5.030
0.430
0.8125
W6X9
5.900
0.170
3.940
0.215
0.5625
W6X12
6.03
0.230
4.000
0.280
0.625
W6X16
6.28
0.260
4.030
0.405
0.750
W6X15
5.99
0.230
5.99
0.260
0.625
W6X20
6.200
0.260
6.020
0.365
0.750
W6X25
6.380
0.320
6.080
0.455
0.8125
W8X10
7.890
0.170
3.940
0.205
0.625
W8X13
7.990
0.230
4.000
0.255
0.6875
W8X15
8.11
0.245
4.015
0.315
0.750

Posted

Why not use the Dynamic Block for a Wide Flange beam - Imperial that is on the Structural tab of your Tool Palettes?

Posted

ReMark,

 

I do, occassionally. I am a structural steel detailer, so I insert a lot of these things. I find the dynamic blocks a little more time-consuming. I'd rather just insert what I want, rather than inserting, and then selecting a size from the dynamic block. I know that I have to make a choice of member size either way, but I think there is an extra pick or two in getting to the drop-down list of sizes using the dynamic block method.

 

It isn't critical that I get Peter's lisp program to work. I have several options for inserting the various structural shapes. His program just seemed like a very fast, clear method of inserting the W shapes.

 

Thank you for the suggestion, though !!

Posted

Change this code:

(if (not (tblsearch "BLOCK" [color=red]BNAMES[/color]))
 (MakeWSBlk (nth WSHPNUM 
WSNLIST))
)

 

 

 

...to this:

(if (not (tblsearch "BLOCK" [color=blue]BLKNAM[/color]))
 (MakeWSBlk (nth WSHPNUM 
WSNLIST))
)

 

 

Works for me now.

Posted

Lonnie,

 

Did you get a dialog box from which to choose a member size? My dialog box was coming up previously, but the insert never happened. Using your suggestion, I didn't get the dialog box, but I was able to insert a shape. The program is crashing in a different location than it did previously. It's as though something in my drawing environment has changed, but I've used either a template drawing or a setup lisp, so there shouldn't be any difference in my starting drawing.

 

Please let me know whether you got the dialog box, or not. Meanwhile, I'll continue to scratch my head here, and see if I can't find out why the program is crashing in a different location than before.

 

Thank you very much for your help !!

Posted
Lonnie,

 

Did you get a dialog box from which to choose a member size? My dialog box was coming up previously, but the insert never happened. Using your suggestion, I didn't get the dialog box, but I was able to insert a shape. The program is crashing in a different location than it did previously. It's as though something in my drawing environment has changed, but I've used either a template drawing or a setup lisp, so there shouldn't be any difference in my starting drawing.

 

Please let me know whether you got the dialog box, or not. Meanwhile, I'll continue to scratch my head here, and see if I can't find out why the program is crashing in a different location than before.

 

Thank you very much for your help !!

 

 

I just tested this:

 (if (not (tblsearch "BLOCK" [color=red]BLKNAM[/color]))

myself and it works great. Do what Lonnie suggests.

I would also suggest you localize the variable BLKNAM too. Try exiting AutoCAD and reload the code with the change and you should be OK.

Posted

Lonnie & Buzzard,

:D

 

 

The change you suggested worked, with a dialog box, in another drawing. I must have something in my latest template and/or in my setup routine that is different than what I was using previously, because I still haven't gotten the IWS.lsp to work in all of the drawings. NUTS !! What did I go and do this time to shoot myself in the foot? :(

 

 

Thank you both for the help !!!

Posted

Were you typing some of the code in the command line of the drawing where the code didn't work? During code testing I will sometimes type individual lines of code into the command line to see where the code breaks. If you've done this then some the variables may be evaluating incorrectly.

 

Save and close the drawing you're having a problem with, then reopen and reload the code and see if that fixes the problem.

 

If that doesn't work, can you upload one of the drawings you have this issue with so someone here can take a look at it?

Posted (edited)

Ok,

 

I noticed a nil echo in the program and the Block Definition needed some clean-up.

I added an error trap to the DCL call.

 

Try This:

 

IWS.lsp

; Written By: Peter Jamtgaard
; This program will create wshape (Beams) using a dialog box or command line entry.
; The cmddia system variable set to 0 will allow the command line entry.
; The program uses parametric data in the iws.txt file to create the wshape as a 
; block with the appropriate name. It also uses a dcl file iws.dcl to control the dialog
; box entry method.
(defun C:IWS (/ WSNLIST)
 (WSHP)
 (if (= (getvar "cmddia")0)
   (progn
     (while
       (not
         (member
           (setq BLKNAM (getstring "\nEnter wshape name: "))
           (mapcar 'car WSNLIST)
         )
       )
       (princ "\nUnrecognized wshape name please try again: ")
     )
     (setq WSHPNUM (- (length (member BLKNAM (reverse (mapcar 'car WSNLIST)))) 1))
   )
   (progn
     (DDWSHP)
     (setq BLKNAM (nth WSHPNUM (mapcar 'car WSNLIST)))
   )
 )
 (if
   (not (tblsearch "BLOCK" [color=red]BLKNAM[/color]))     [color=black];Edit variable By The Buzzard 11.16.10[/color]
   (MakeWSBlk (nth WSHPNUM WSNLIST))
 )
 (command "insert" BLKNAM pause "1" "1" pause)
 (princ)
)
; Import parametric information from iws.txt text file into a list.
(defun WSHP (/ WSHPDATA WNAME DEPTHR TWR WIDTHR TFR KR)
 (setq z (open (findfile "IWS.TXT") "r"))
 (if (not WSNLIST)
   (progn
     (setq B 0 C -1)
     (while
       (setq BLKNAM (read-line z))        
       (setq DEPTHR (atof (read-line z))
             TWR    (atof (read-line z))
             WIDTHR (atof (read-line z))
             TFR    (atof (read-line z))
             KR     (atof (read-line z))
             WSHPDATA (list BLKNAM DEPTHR TWR WIDTHR TFR KR)
             WSNLIST  (cons WSHPDATA WSNLIST))
     )
     (setq WSNLIST (reverse WSNLIST))
   )
 )
 (close z)
 (princ)
)
; IWS dialog box wshape selection box.
(defun DDWSHP ()
 (if
   (= WSHPNUM nil)
   (setq WSHPNUM 1)
 )
 (setq id (load_dialog "iws.dcl"))
[color=red](if (not (new_dialog "pickw" id))  ; Edited DCL CALL by The Buzzard 11.16.10[/color]
[color=red](progn[/color]
[color=red](ALERT[/color]
[color=red] (strcat[/color]
[color=red]   "\nAttention!"[/color]
[color=red]   "\n"[/color]
[color=red]   "\nThe dialog file IWS.dcl could not be found."[/color]
[color=red]   "\nBe sure the dialog file IWS.dcl"[/color]
[color=red]   "\nis in the AutoCAD Support File Search Path."))[/color]
[color=red](exit)[/color]
[color=red])[/color]
[color=red])[/color]
 (start_list "wshapes")
 (mapcar 'add_list (mapcar 'car WSNLIST))
 (end_list)
 (set_tile "wshapes" (itoa WSHPNUM))
 (action_tile "wshapes" "(progn (setq WSHPNUM (atoi $value))(princ WSHPNUM))")
 (if (= (start_dialog) 1) WSHPNUM nil)
 (princ)
)
(defun MakeWSblk (WSHPDATA / BLKNAM DEPTHR TWR WIDTHR TFR KR)
 (setq BLKNAM (nth 0 WSHPDATA)
       DEPTHR (nth 1 WSHPDATA)
       TWR    (nth 2 WSHPDATA)
       WIDTHR (nth 3 WSHPDATA)
       TFR    (nth 4 WSHPDATA)
       KR     (nth 5 WSHPDATA) )
[color=red]  (entmake                           ;Edited Block Definition by the Buzzard 11.16.10[/color]
[color=red]    (list [/color]
[color=red]      (cons 0  "BLOCK")[/color]
[color=red]      (cons 2   BLKNAM)[/color]
[color=red]      (cons 70  0)[/color]
[color=red]      (cons '10 (list 0.0 0.0 0.0))[/color]
[color=red]    )[/color]
[color=red]  )[/color]
[color=red](entmake [/color]
[color=#ff0000] (list [/color]
[color=red](cons 0   "LWPOLYLINE")[/color]
[color=red](cons 5   "AD")[/color]
[color=red](cons 100 "AcDbEntity")[/color]
[color=red](cons 67   0)[/color]
[color=red](cons 410 "Model")[/color]
[color=red](cons 8   "0")[/color]
[color=red](cons 100 "AcDbPolyline")[/color]
[color=red](cons 90   16)[/color]
[color=red](cons 70   1)[/color]
[color=red](cons 43   0.0)[/color]
[color=red](cons 38   0.0)[/color]
[color=red](cons 39   0.0)[/color]
[color=red](list 10 (* -1 (/ WIDTHR 2.0)) (* -1 (/ DEPTHR 2.0)))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (/ WIDTHR 2.0) (* -1 (/ DEPTHR 2.0)))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (/ WIDTHR 2.0) (+ TFR (* -1 (/ DEPTHR 2.0))))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (+ (/ TWR 2.0) KR) (+ TFR (* -1 (/ DEPTHR 2.0))))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42  -0.414214)[/color]
[color=red](list 10 (/ TWR 2.0) (+ KR TFR (* -1 (/ DEPTHR 2.0))))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (/ TWR 2.0) (- (/ DEPTHR 2.0) KR TFR))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42  -0.414214)[/color]
[color=red](list 10 (+ (/ TWR 2.0) KR) (- (/ DEPTHR 2.0) TFR))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (/ WIDTHR 2.0) (- (/ DEPTHR 2.0) TFR))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (/ WIDTHR 2.0) (/ DEPTHR 2.0))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (/ WIDTHR -2.0) (/ DEPTHR 2.0))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (/ WIDTHR -2.0) (- (/ DEPTHR 2.0) TFR))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (* -1 (+ (/ TWR 2.0) KR)) (- (/ DEPTHR 2.0) TFR))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42  -0.414214)[/color]
[color=red](list 10 (* -1 (/ TWR 2.0)) (- (/ DEPTHR 2.0) KR TFR))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (* -1 (/ TWR 2.0)) (* -1 (- (/ DEPTHR 2.0) KR TFR)))  [/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42  -0.414214)[/color]
[color=red](list 10 (* -1 (+ KR (/ TWR 2.0))) (+ TFR (* -1 (/ DEPTHR 2.0))))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](list 10 (* -1 (/ WIDTHR 2.0)) (+ TFR (* -1 (/ DEPTHR 2.0))))[/color]
[color=red](cons 40   0.0)[/color]
[color=red](cons 41   0.0)[/color]
[color=red](cons 42   0.0)[/color]
[color=red](cons 210 (list 0.0 0.0 1.0))[/color]
[color=red]) [/color]
[color=red])[/color]
[color=red](entmake[/color]
[color=red](list[/color]
[color=red](cons 0  "endblk")[/color]
[color=red])[/color]
[color=red])[/color]
[color=red](princ)[/color]
[color=red])[/color]

 

 

IWS.dcl

pickw : dialog { label="Insert W Shapes";
       : list_box { key = "wshapes"; height = 10; width = 5; multiple_select = true; allow_accept = true; }
 ok_cancel;
}

 

 

IWS.TXT

W4X13
4.160
0.280
4.060
0.345
0.687
W5X16
4.68
0.240
5.000
0.360
0.750
W5X19
5.15
0.270
5.030
0.430
0.8125
W6X9
5.900
0.170
3.940
0.215
0.5625
W6X12
6.03
0.230
4.000
0.280
0.625
W6X16
6.28
0.260
4.030
0.405
0.750
W6X15
5.99
0.230
5.99
0.260
0.625
W6X20
6.200
0.260
6.020
0.365
0.750
W6X25
6.380
0.320
6.080
0.455
0.8125
W8X10
7.890
0.170
3.940
0.205
0.625
W8X13
7.990
0.230
4.000
0.255
0.6875
W8X15
8.11
0.245
4.015
0.315
0.750

Edited by The Buzzard

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...