Exchange Forum >
Dcl Dialogs
C Shapes
Theodorus Winata
Join Date:
11-15-2007
Hello J Briggs,
I copied and renamed W Shapes written by Trevor and fixed by you to Cshapes.lsp. When I ran the program, it left an error message, Data for C9x25 flange not found when I selected C9 from the dialog box. Could you please take a look into it and tell me how to fix it?
Thank you,
Theodorus Winata
Attachments
Cshapes.dcl
Cshapes.lsp
J Briggs
Join Date:
07-25-2007
The main problem was that the weight for c-shapes is not an integer as was the case for w-shapes. So I add a few comments out to the right starting with ";was something". Look at those to see the difference. I tested your code with a C10x30 and it does toggle between the list for 9s and 10s so you definitely have that down right. I think your insertion point may be off, but I think you can solve that later.
Good job so far,
J Briggs
Code:
; c:Cshapes2 dialog function to draw Cshapes
(defun c:Cshapes2 (/ Change_Weights Check_Angle Dcl_Id Depth Depths DepthWeight
InsAng OldInsAng Return Weight Weights)
; Change_Weights subfunction
(defun Change_Weights ()
(setq Depth (nth (atoi $value) Depths))
(setq Weights (cdr (assoc Depth DepthWeight)))
(if (not (member Weight Weights))
(setq Weight (nth 0 Weights))
)
(start_list "WeightList")(mapcar 'add_list Weights)(end_list)
(set_tile "WeightList" (itoa (- (length Weights) (length (member Weight Weights)))))
)
; Check_Angle subfunction
(defun Check_Angle (/ Prec)
(if (and (= (atof $value)(distof $value 2))
(>= (atof $value) 0)(< (atof $value) 360))
(progn
(setq Prec 0)
(setq Value (atof $value))
(while (/= Value (atoi (rtos Value 2 Prec)))
(setq Value (* Value 10))
(setq Prec (1+ Prec))
)
(setq InsAng (rtos (atof $value) 2 Prec))
)
(progn
(alert "The Insertion Angle must be a real\nnumber between 0 and less than 360.")
(setq InsAng OldInsAng)
)
)
(set_tile "AngleEdit" InsAng)
(setq OldInsAng InsAng)
)
; Main code for c:Cshapes dialog function
(CshapeLists)
(if (not CshapesInfo)
(setq CshapesInfo (list "9" "25.40" "90"))
)
(setq Depth (nth 0 CshapesInfo))
(setq Weight (nth 1 CshapesInfo))
(setq InsAng (nth 2 CshapesInfo))
(setq OldInsAng InsAng)
(setq Weights (cdr (assoc Depth DepthWeight)))
(if (not (member Weight Weights))
(setq Weight (nth 0 Weights))
)
(setq Dcl_Id (load_dialog "Cshapes.dcl"))
(new_dialog "Cshapes" Dcl_Id)
(set_tile "DepthText" "Depth Dimension")
(start_list "DepthList")(mapcar 'add_list Depths)(end_list)
(set_tile "DepthList" (itoa (- (length Depths) (length (member Depth Depths)))))
(set_tile "WeightText" "Pounds per Foot")
(start_list "WeightList")(mapcar 'add_list Weights)(end_list)
(set_tile "WeightList" (itoa (- (length Weights) (length (member Weight Weights)))))
(set_tile "AngleText" "Insertion Angle")
(set_tile "AngleEdit" InsAng)
(action_tile "DepthList" "(Change_Weights)")
(action_tile "WeightList" "(setq Weight (nth (atoi $value) Weights))")
(action_tile "AngleEdit" "(Check_Angle)")
(setq Return (start_dialog))
(unload_dialog Dcl_Id)
(setq CshapesInfo (list Depth Weight InsAng))
(if (= Return 0) (exit))
(DrawCshape (atoi Depth)(atof Weight)(atof InsAng));was (atoi Weight)
(princ)
)
; DrawCshape function draCs Cshape flange
(defun DrawCshape (Depth Weight InsAng / Clayer Data DistK
FlangeDep FlangeThk FlangeWth Osmode P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 PromptStr WebThk)
(setq PromptStr (strcat "\nSpecify corner of C" (itoa Depth) "x" (rtos Weight 2 2) " flange: "));was (itoa Weight)
(if (not (setq P1 (getpoint PromptStr))) (exit))
(foreach Data DataList
(if (and (= (nth 0 Data) Depth)(= (nth 1 Data) Weight))
(progn
(setq Clayer (getvar "clayer"))
(setq Osmode (getvar "osmode"))
(command "undo" "begin")
(setvar "osmode" 0)
(setq FlangeDep (nth 2 Data))
(setq WebThk (nth 3 Data))
(setq FlangeWth (nth 4 Data))
(setq FlangeThk (nth 5 Data))
(setq DistK (nth 6 Data))
(setq P1 (List (CAR P1) (+ (CADR P1) FlangeDep)))
(setq P10 (List (CAR P1) (- (CADR P1) FlangeDep)))
(setq P9 (List (+ (CAR P10) FlangeWth) (CADR P10)))
(setq P2 (List (+ (CAR P1) FlangeWth) (CADR P1)))
(setq P3 (List (- (CAR P2) FlangeThk) (- (CADR P2) FlangeThk)))
(setq P4 (List (+ (CAR P1) (* WebThk 2)) (- (CADR P1) (- DistK WebThk))))
(setq P5 (List (- (CAR P4) WebThk) (- (CADR P1) DistK)))
(setq P6 (List (CAR P5) (+ (CADR P10) DistK)))
(setq P7 (List (+ (CAR P6) WebThk) (+ (CADR P10) (- DistK WebThk))))
(setq P8 (List (- (CAR P9) FlangeThk) (+ (CADR P9) FlangeThk)))
;(command "layer" "s" "Object" "");Revise as needed
(command "pline" P1 "w" "0" "0" P2 "a" "d" "270" P3 "l" P4
"a" P5 "l" P6 "a" P7 "l" P8 "a" P9 "l" P10 "c")
(command "rotate" "l" "" P1 InsAng)
(command "layer" "m" "S_hatch35s" "c" "253" "S_hatch35s" "");Revise as needed
(command "hatch" "steel" FlangeWth InsAng "l" "");Remove if not needed
(setvar "clayer" Clayer)
(setvar "osmode" Osmode)
(command "undo" "end")
)
)
)
(if (not FlangeDep)
(princ (strcat "\nData for C" (itoa Depth) "x" (rtos Weight 2 2) " flange not found."));was (itoa Weight)
)
)
; CshapeLists function creates DataList, DepthWeight, and Depths lists
(defun CshapeLists (/ Data Info Num X)
(setq DataList (list;Depth Weight FlangeDep WebThk FlangeWth FlangeThk DistK
(list 9 25.40 9.000 0.450 3.500 0.550 1.1875)
(list 9 23.90 9.000 0.400 3.450 0.550 1.1875)
)
)
(setq DepthWeight nil)
(setq Depths (vl-sort (mapcar 'car DataList) '<))
(foreach Num Depths
(setq Data nil)
(foreach Info DataList
(if (= (car Info) Num)
(setq Data (append Data (list (cadr Info))))
)
)
(setq Info (cons (rtos Num 2 0) (mapcar '(lambda (X) (rtos X 2 2)) (vl-sort Data '<))));was (rtos X 2 0)
(setq DepthWeight (append DepthWeight (list Info)))
)
(setq Depths (mapcar '(lambda (X) (rtos X 2 0)) Depths))
)
(princ)
Theodorus Winata
Join Date:
11-15-2007
J Briggs,
Thanks for your valuable help to fix the program and thanks to Trevor to use his W Shapes as a base program. Well done to both of you.
Thank you,
Theodorus Winata
Trevor
Join Date:
07-29-2007
I'm thinking about changing the first two items in the Wshapes DataList to strings instead of numbers. I think it will be easier to work with. I thought I might need to sort the Depths and Weights but they are already in a sorted order in the DataList. I'll keep you posted when I finish with that. Good luck on working through Cshapes. I think is going to be a great drawing tool.
Trevor
Here's the start of what I'm revising for Wshapes:
Code:
(setq DataList (list;Depth Weight FlangeDep WebThk FlangeWth FlangeThk
(list "4" "13" 4.16 0.280 4.060 0.345)
(list "5" "16" 5.01 0.240 5.000 0.360)
(list "5" "19" 5.15 0.270 5.030 0.430)