;;; Choices ;;;
(initget "Yes No")
(setq ch (getkword "\nIs this going to be a Multi-Member Unit? [Yes or No] <No>: "); If the answer is yes then I want to ask this next question
(if (= ch "Yes")
(progn
(initget "2 3 4")
(setq ans (getkword "\nHow many members will make up this Multi-Member Unit? (2, 3, or 4) <2> ")
); End setq
); End prognn
(progn
(setq sp '(0 0)
wid (getreal "\nWhat is the width of this Member Shape? ")
dep (getreal "\nWhat is the depth of this Member Shape? ")
memshna (getstring T "\nWhat is the name of the Member Shape? ")
); End setq
); End progn
); End if
); End setq
(initget "Yes No")
(if (setq ch (= (getkword "\nIs this going to be a Multi-Member Unit? [Yes or No] <No>: ") "Yes"))
;; ONLY USE ch if you need it, in this case ch=true when YES else ch=nil
(progn
(initget "2 3 4")
(if (null (setq ans (getkword "\nHow many members will make up this Multi-Member Unit? (2, 3, or 4) <2> ")))
(setq ans "2")
)
)
(setq sp '(0 0)
wid (getreal "\nWhat is the width of this Member Shape? ")
dep (getreal "\nWhat is the depth of this Member Shape? ")
memshna (getstring t "\nWhat is the name of the Member Shape? ")
) ; End setq
) ; End if
(initget "Yes No")
(if (or (setq opt (getkword "\nSelect an option [Yes/No] <Yes>: "))
(= nil opt))
;; Either yes, no, or enter (right click) selected
(prompt (strcat "\nYou selected " opt))
;; Nothing selected
)
Code, code, code
(if (= ch "Yes")
(progn
;;; Let's Define the Double Multi-Member Shape & Style ;;;
(cond ((= ans 2)
(setq memstyna (getstring T "\nWhat is the Member Style Name going to be? ")); End setq
(shapename)
(princ "Hi")
(command "-MemberStyle"
"_New" memstyna
"_Component" "_Edit" "1" "_Name" "Section" "STart"
"_SHape" memshna "" "_ENd" "_SHape" memshna "" ""
"_Add" "_Edit" "2" "_Name" "Section" "_Start" "_SHape"
memshna "_Offset" "" wid "" "" "_ENd" "_SHape" memshna
"_Offset" "" "" "" "" "" "" "" "" ""
); End command
); End predicate1
;;; Let's Define the Triple Multi-Member Shape & Style ;;;
((= ans 3)
(setq memstyna (getstring T "\nWhat is the Member Style Name going to be? ")); End setq
(shapename)
(command "-MemberStyle"
"_New" memstyna
"_Component" "_Edit" "1" "_Name" "Section" "STart"
"_SHape" memshna "" "_ENd" "_SHape" memshna "" ""
"_Add" "_Edit" "2" "_Name" "Section" "_Start" "_SHape"
memshna "_Offset" "" wid "" "" "_ENd" "_SHape" memshna
"_Offset" "" "" "" "" "" "" "" "" ""
); End command
); End predicate2
;;; Let's Define the Quadruple Multi-Member Shape & Style ;;;
((= ans 4)
(setq memstyna (getstring T "\nWhat is the Member Style Name going to be? ")); End setq
(shapename)
(command "-MemberStyle"
"_New" memstyna
"_Component" "_Edit" "1" "_Name" "Section" "STart"
"_SHape" memshna "" "_ENd" "_SHape" memshna "" ""
"_Add" "_Edit" "2" "_Name" "Section" "_Start" "_SHape"
memshna "_Offset" "" wid "" "" "_ENd" "_SHape" memshna
"_Offset" "" "" "" "" "" "" "" "" ""
); End command
); End predicate3
); End cond
); End progn
;;; Let's Define the Unequal Multi-Member Shape & Style ;;;
;;; Maybe something here
;;; Let's Define the Member Shape & Style ;;;
(progn
(setq memstyna (getstring T "\nWhat is the Member Style Name going to be? ")); End setq
(shapename)
(command "-MemberStyle"
"_New" memstyna
"_Component" "_Edit" "1" "_Name" "Section"
"_STart" "_SHape" memshna "" "_ENd" "_SHape"
memshna "" "" "" "" ""
); End command
); end progn
); end if
(cond
((= ans "2")
(...)(...)(...)
)
((= ans "3")
(....)
)
); End of cond
Code: [Select](if
(or
(setq opt (getkword "\nSelect an option [Yes/No] <Yes>: "))
(= nil opt)
)
...
)
;; Copyright© 2012 by Nick Haury ;;;
;;;;**************************************************************;;;;
(defun *error* (msg);
(if (/= msg "Function cancelled") ;
(princ (strcat "\nAutoLISP Error: " msg)) ;
(terpri);
);
(setvar "CMDECHO" S_CMD) ;
(setvar "ORTHOMODE" S_ORTH) ;
(setvar "OSMODE" S_OSM) ;
(command "-layer" "s" CL "" "redraw") ;
); End defun
;;
;; Subroutine to Start program
(defun start () ;
(graphscr) ;
(setq CL (getvar "CLAYER")) ; Stores Current Layer;
(setq S_CMD (getvar "CMDECHO")) ; Stores Command Mode State;
(setq S_ORTH (getvar "ORTHOMODE")) ; Stores Orthomode State;
(setq S_OSM (getvar "OSMODE")) ; Stores Object Snap State;
(setvar "CMDECHO" 1) ; No echo;
(setvar "ORTHOMODE" 1) ; Ortho on;
(setvar "OSMODE" 0) ; Snap None;
); End defun
;;
;; Subroutine to end program
(defun Stop () ;
(setvar "CMDECHO" S_CMD) ; Restores Stored Command Echo
(setvar "OSMODE" S_OSM) ; Restores Stored Object Snap
(command "-LAYER" "s" CL "") ; Restores Current Layer State
); End defun
(defun shapename ()
(command "_-AecsMemberShapeDefine"
"_New" memshna
"_Graphics"
"_Low" (entlast) "" p2
"_Medium" (entlast) p2
"_High" (entlast) p2 "" "" ""
); End command
(entdel (entlast))
); End defun
;;; Start Routine ;;;
(defun c:smc ()
(start)
;;; Choices ;;;ze
(initget "Yes No")
(if (setq ch (= (getkword "\nIs this going to be a Multi-Member Unit? [Yes or No] <No>: ") "Yes"))
(progn
(initget "2 3 4")
(if (null (setq ans (getkword "\nHow many members will make up this Multi-Member Unit? (2, 3, or 4) <2> ")))
(setq ans "2")
); End if
(setq sp '(0 0)
wid (getreal "\nWhat is the width of this Member Shape? ")
dep (getreal "\nWhat is the depth of this Member Shape? ")
memshna (getstring t "\nWhat is the name of the Member Shape? ")
); End setq
); End progn
(setq sp '(0 0)
wid (getreal "\nWhat is the width of this Member Shape? ")
dep (getreal "\nWhat is the depth of this Member Shape? ")
memshna (getstring t "\nWhat is the name of the Member Shape? ")
); End setq
); End if
;;; Do the Math ;;;
(setq x1 (car sp)
x2 (+ x1 (/ wid 2.0))
x3 (+ x1 wid)
y1 (cadr sp)
y2 (+ y1 dep)
); End setq
;;; Point Assignment ;;;
(setq p1 (list x1 y1)
p2 (list x2 y1)
p3 (list x3 y1)
p4 (list x3 y2)
p5 (list x1 y2)
); End setq
;;; Lets Draw ;;;
(command
"_.pline" p1 p3 p4 p5 "c"
); End command
;;; Let's Define the Multi-Member Shapes & Styles ;;;
(if (= ch "Yes")
(progn
;;; Let's Define the Double Multi-Member Shape & Style ;;;
(cond ((= ans 2)
(progn
(setq memstyna (getstring T "\nWhat is the Member Style Name going to be? ")); End setq
(shapename)
(command "-MemberStyle"
"_New" memstyna
"_Component" "_Edit" "1" "_Name" "Section" "STart"
"_SHape" memshna "" "_ENd" "_SHape" memshna "" ""
"_Add" "_Edit" "2" "_Name" "Section" "_Start" "_SHape"
memshna "_Offset" "" wid "" "" "_ENd" "_SHape" memshna
"_Offset" "" "" "" "" "" "" "" "" ""
); End command
); End progn
); End predicate1
;;; Let's Define the Triple Multi-Member Shape & Style ;;;
((= ans 3)
(progn
(setq memstyna (getstring T "\nWhat is the Member Style Name going to be? ")); End setq
(shapename)
(command "-MemberStyle"
"_New" memstyna
"_Component" "_Edit" "1" "_Name" "Section" "STart"
"_SHape" memshna "" "_ENd" "_SHape" memshna "" ""
"_Add" "_Edit" "2" "_Name" "Section" "_Start" "_SHape"
memshna "_Offset" "" wid "" "" "_ENd" "_SHape" memshna
"_Offset" "" "" "" "" "" "" "" "" ""
); End command
); End progn
); End predicate2
;;; Let's Define the Quadruple Multi-Member Shape & Style ;;;
((= ans 4)
(progn
(setq memstyna (getstring T "\nWhat is the Member Style Name going to be? ")); End setq
(shapename)
(command "-MemberStyle"
"_New" memstyna
"_Component" "_Edit" "1" "_Name" "Section" "STart"
"_SHape" memshna "" "_ENd" "_SHape" memshna "" ""
"_Add" "_Edit" "2" "_Name" "Section" "_Start" "_SHape"
memshna "_Offset" "" wid "" "" "_ENd" "_SHape" memshna
"_Offset" "" "" "" "" "" "" "" "" ""
); End command
); End progn
); End predicate3
); End cond
); End progn
;;; Let's Define the Unequal Multi-Member Shape & Style ;;;
;;; Maybe something here
;;; Let's Define the Member Shape & Style ;;;
(progn
(setq memstyna (getstring T "\nWhat is the Member Style Name going to be? ")); End setq
(shapename)
(command "-MemberStyle"
"_New" memstyna
"_Component" "_Edit" "1" "_Name" "Section"
"_STart" "_SHape" memshna "" "_ENd" "_SHape"
memshna "" "" "" "" ""
); End command
); end progn
); end if
(princ)
(stop)
); End C:SMC
(setq ch (= (getkword "\nIs this going to be a Multi-Member Unit? [Yes or No] <No>: ") "Yes"))
(= (setq ch (getkword "\nIs this going to be a Multi-Member Unit? [Yes or No] <No>: ")) "Yes")
OOOKKKay, uh, where and how would I use this? :|
Soooo, I won't use the 'IF' here at this point?
Code: [Select](if
(or
(= "Yes" (setq opt (getkword "\nSelect an option [Yes/No] <Yes>: ")))
(= nil opt)
)
;; Yes, or Enter
;; No
)
This says: "If (<opt> or (not <opt>)): do this ..."
The IF statement is redundant since the 'else' expression will NEVER be evaluated (<opt> can only be nil or non-nil).
You know something, I am a firm believer that you browbeat, criticize, or just talk negatively to some one in front of everyone.
Hmmmm, whats that? If I should have pasted the code as an attachment, then I'm sorry. If so how would I do that? If that is not the case, then what are you talking about? Is that better? I was wondering if that was what it was for. Uh next time, why don't you do a private email and clue me in then wasting the time to do this. Sorry I offended you.Srr..English isn't my language
;; Copyright© 2012 by Nick Haury ;;;
;;;;**************************************************************;;;;
;; NOTE by CAB
;; I made some assumptions which affects my changes to your routine.
;;; Start Routine ;;;
(defun c:smc (/ ; LOCAL variables follow
*error* ; error routine declaried local
mbrs ch cl dep memshna memstyna p1 p2 p3 p4 p5 sp s_cmd s_orth s_osm wid x1 x2 x3 y1 y2
)
;; NOTE: error routines should be made LOCAL and placed with in the main defun
;; During testing the error routine should be disab;ed as you do not want
;; to trap any errors, so use
;| this disables the error routine
(defun *error* (msg);
(if (/= msg "Function cancelled") ;
(princ (strcat "\nAutoLISP Error: " msg)) ;
(terpri);
);
(setvar "CMDECHO" S_CMD) ;
(setvar "ORTHOMODE" S_ORTH) ;
(setvar "OSMODE" S_OSM) ;
(command "-layer" "s" CL "" "redraw") ;
); End defun
|; ; end of error routine disable
;; Subroutine to end program
;; subroutines should be cantained within the main defun unless thay are used
;; by other routines, in that case they are libriary routines
(defun shapename (p) ; point is passed here from calling function
(command "_-AecsMemberShapeDefine"
"_New" memshna "_Graphics" "_Low" (entlast) ""
p "_Medium" (entlast)
p "_High" (entlast)
p "" "" ""
) ; End command
(entdel (entlast))
) ; End defun
;; (start) ; use only if you have a library routine or is called more than once, else include code here
;; you want to keep your variables LOCAL if you can
(graphscr) ;
(setq cl (getvar "CLAYER")) ; Stores Current Layer;
(setq s_cmd (getvar "CMDECHO")) ; Stores Command Mode State;
(setq s_orth (getvar "ORTHOMODE")) ; Stores Orthomode State;
(setq s_osm (getvar "OSMODE")) ; Stores Object Snap State;
(setvar "CMDECHO" 1) ; No echo;
(setvar "ORTHOMODE" 1) ; Ortho on;
(setvar "OSMODE" 0) ; Snap None;
;; Choices ;;;ze
(initget "Yes No")
(if (= (getkword "\nIs this going to be a Multi-Member Unit? [Yes or No] <No>: ") "Yes")
(progn
(initget "2 3 4")
(if (null
(setq mbrs (getkword "\nHow many members will make up this Multi-Member Unit? (2, 3, or 4) <2> "))
)
(setq mbrs "2")
) ; End if
) ; End progn
(setq mbrs "1")
) ; End if
(setq sp '(0 0))
(initget (+ 1 2 4))
(setq wid (getreal "\nWhat is the width of this Member Shape? "))
(initget (+ 1 2 4))
(setq dep (getreal "\nWhat is the depth of this Member Shape? "))
(setq memshna (getstring t "\nWhat is the name of the Member Shape? "))
;; ERROR check befor proceeding
(if (and ; all the following must be true or (not nill)
(> wid 0)
(> dep 0)
(/= "" memshna)
)
(progn
;; Do the Math ;;;
(setq x1 (car sp)
x2 (+ x1 (/ wid 2.0))
x3 (+ x1 wid)
y1 (cadr sp)
y2 (+ y1 dep)
) ; End setq
;; Point Assignment ;;;
(setq p1 (list x1 y1)
p2 (list x2 y1)
p3 (list x3 y1)
p4 (list x3 y2)
p5 (list x1 y2)
) ; End setq
;; Lets Draw ;;;
(command "_.pline" p1 p3 p4 p5 "c")
;; Let's Define the Multi-Member Shapes & Styles ;;;
(cond
((= mbrs "1")
(setq memstyna (getstring t "\nWhat is the Member Style Name going to be? ")) ; End setq
(shapename p2)
(command "-MemberStyle" "_New" memstyna "_Component" "_Edit" "1" "_Name" "Section" "_STart" "_SHape" memshna ""
"_ENd" "_SHape" memshna "" "" "" "" ""
) ; End command
) ; End predicate1
((= mbrs "2")
(progn
(setq memstyna (getstring t "\nWhat is the Member Style Name going to be? ")) ; End setq
(shapename p2)
(command "-MemberStyle" "_New" memstyna "_Component" "_Edit" "1" "_Name" "Section" "STart" "_SHape" memshna ""
"_ENd" "_SHape" memshna "" "" "_Add" "_Edit" "2" "_Name" "Section" "_Start" "_SHape" memshna "_Offset"
"" wid "" "" "_ENd" "_SHape" memshna "_Offset" "" "" "" "" "" "" "" "" ""
) ; End command
) ; End progn
) ; End predicate2
;; Let's Define the Triple Multi-Member Shape & Style ;;;
((= mbrs "3")
(progn
(setq memstyna (getstring t "\nWhat is the Member Style Name going to be? ")) ; End setq
(shapename p2)
(command "-MemberStyle" "_New" memstyna "_Component" "_Edit" "1" "_Name" "Section" "STart" "_SHape" memshna ""
"_ENd" "_SHape" memshna "" "" "_Add" "_Edit" "2" "_Name" "Section" "_Start" "_SHape" memshna "_Offset"
"" wid "" "" "_ENd" "_SHape" memshna "_Offset" "" "" "" "" "" "" "" "" ""
) ; End command
) ; End progn
) ; End predicate3
;; Let's Define the Quadruple Multi-Member Shape & Style ;;;
((= mbrs "4")
(setq memstyna (getstring t "\nWhat is the Member Style Name going to be? ")) ; End setq
(shapename p2)
(command "-MemberStyle" "_New" memstyna "_Component" "_Edit" "1" "_Name" "Section" "STart" "_SHape" memshna ""
"_ENd" "_SHape" memshna "" "" "_Add" "_Edit" "2" "_Name" "Section" "_Start" "_SHape" memshna "_Offset" ""
wid "" "" "_ENd" "_SHape" memshna "_Offset" "" "" "" "" "" "" "" "" ""
) ; End command
) ; End predicate4
) ; End cond
) ; progn
(princ "\n*** Error in user input ***")
) ; endif
(princ)
;;(stop) ; use only if you have a library routine or is called more than once, else include code here
(setvar "CMDECHO" s_cmd) ; Restores Stored Command Echo
(setvar "OSMODE" s_osm) ; Restores Stored Object Snap
(command "-LAYER" "s" cl "") ; Restores Current Layer State
) ; End C:SMC
Command: _-AECSMEMBERSHAPEDEFINE
Shape [New/Copy/Edit/Purge/?]: n
New style name or [?]: 2x12
New style 2x12 created.
Shape definition [Name/Description/Graphics]: G
Shape designation [Low detail/Medium detail/High detail]: L
Select lines, arcs, circles, or polylines for Low Detail: Here I put (entlast) and it returns: 1 found
Select lines, arcs, circles, or polylines for Low Detail: <enter out of command>
Insertion point or [Add entity]:Here is put the defined point 'p2'
Shape designation [Low detail/Medium detail/High detail]: M
Select a closed polyline, spline, ellipse, or circle for an outer ring:Here I put (entlast)
Insertion point or [Add ring/Centroid]:Here is put the defined point 'p2'
Shape designation [Low detail/Medium detail/High detail]: H
Select a closed polyline, spline, ellipse, or circle for an outer ring:Here I put (entlast)
Insertion point or [Add ring/Centroid]:Here is put the defined point 'p2'
Shape designation [Low detail/Medium detail/High detail]: <enter out of command>
Shape definition [Name/Description/Graphics]: <enter out of command>
Shape [New/Copy/Edit/Purge/?]: <enter out of command>
That's not what I'm asking it to do, the memshna is used the same but in diferent conditions. Here are the questions that the command line asks and the answers I put.
So you see the line of code is just the answers to the above question, and I don't need 'p'
I'm sorry, I just don't understand. Again, I'm sorry.http://exchange.autodesk.com/autocad/enu/online-help/search#WS73099cc142f4875516d84be10ebc87a53f-7c3f.htm