Jump to content

Search the Community

Showing results for tags 'cond'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions

Categories

  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Found 6 results

  1. Hello all - I'm jim - New to forum, and auto cad. Over the last few weeks ive been using this site and others to learn AutoCad. I have gleaned lots of useful information however i'm struggling with UCS rotations/ Drawing 3D in a lsp. I'm half way through developing my first lsp that calculates the difference in X,Y,Y. It then draws lines showing deviation directions (for example deviation from design). X and Y devition lines seem to be working ( not fully tested negative coordinates yet) but I cannot resolve the Z line. I have highlighted area that is causing problems. and have attached a screen dump of current results. I know it is probably somthing simple I am missing, but I think i have been looking at the problem t0o long, with too much autocad inexperience If anyone has any ideas or pointers please let me know. Regards JM ;Written by JM 2019 ;STILL UNDER CONSTRUCTION (defun rtd (r) (/ (* r 180.0) pi)) ;Angle conversions (defun dtr (d) (/ (* d pi) 180.0)) ;Angle conversions (defun c:delta (/ p1 p2 x1 x2 y1 y2 z1 z2 xp yp zp dx dy dz coorddiff Tolerence) (command "_UCS" "World") ;Ensure WCS is current (setq osm (getvar "osmode") ocmd (getvar "cmdecho") textStyle (getvar "textstyle") ) ;(setq Tolerence (getdist "\nTolorence in mm : ")) (while (setq p1 (getpoint "\nPick Design Position: ")) (setq x1 (car p1)) (setq y1 (cadr p1)) (setq z1 (caddr p1)) (setq p2 (getpoint "\nPick Asbuilt Position: ")) (setq x2 (car p2)) (setq y2 (cadr p2)) (setq z2 (caddr p2)) (cond ((<= x1 x2) (setq dx (rtos (- x2 x1))) (setq xp (polar p2 (dtr 0) 50)) (command "line" p2 xp "") ) ;_ end of the first condition x ((> x1 x2) (setq dx (rtos (- x1 x2))) (setq xp (polar p2 (dtr 0) -50)) (command "line" p2 xp "") ) ;_ end of the first condition x ) ;_ end of cond statement for X (cond ((<= y1 y2) (setq dy (rtos (- y2 y1))) (setq yp (polar p2 (dtr 90) 50)) (command "line" p2 yp "") ) ;_ end of the first condition y ((>= y1 y2) (setq dx (rtos (- y1 y2))) (setq yp (polar p2 (dtr 90) -50)) (command "line" p2 yp "") ) ;_ end of the second condition y ) ;_ end of cond statement for y ;**********************************************************Rotation Causing 3D Line issue? (cond ((<= z1 z2) (setq dz (rtos (- z2 z1))) (command "_UCS" "y" -90) (setq zp (polar p2 (dtr 180) -50)) (command "line" p2 zp "") ) ;_ end of the first condition z ((> z1 z2) (setq dz (rtos (- z1 z2))) (command "_UCS" "y" -90) (setq zp (polar p2 (dtr 180) 50)) (command "line" p2 zp "") ) ;_ end of the second condition z ) ;_ end of cond statement for z ;**********************************************************Rotation Causing 3D Line issue? ;;Displayes co-ordinates (command "_UCS" "World") (setq coorddiff (strcat dx "," dy "," dz)) (command "text" "j" "c" p2 25 -45 coorddiff) ) )
  2. I'm having trouble with a conditional statement. This code appears to do the math correctly, but it is supposed to return the minimum size conduit that I can use for the wire size entered. For example... Command: CCC Enter phase 1 or 3: 1 Enter feeder size with # (pound) sign (ex:#4/0 or #250): Feeder: #2 Enter ground size with # (pound) sign (ex:#4/0 or #250): Ground: #6 Result: Wire area 0.5238 is < 0.8200, use 1" conduit. The math is correct for the wireArea @ 0.5238, but the conditional statement returns the < 0.8200 (which is for 1-1/2" conduit), and tells me to use 1" conduit (which should be 1-1/4" conduit since the wire area is greater than 0.3400 for 1" conduit, but less than 0.6000 for 1-1/4" conduit). I have placed the result statement within a conditional phrase, for which I believe should evaluate the first correct (true) response, and ignore all others. I do not understand why am getting the text from the conditional statement prior to the true statement, then getting the conduit area value from the conditional statement after the true statement. Hopefully this description makes sense. Perhaps the code will illustrate it better. Please let me know how I have goofed this code. Thanks. (defun c:ccc (/ phse num fs gs wireArea cc) (setq cc nil) ;;; conductor area (setq #14 0.0206 #12 0.0251 #10 0.0311 #8 0.0598 #6 0.0819 #4 0.1087 #3 0.000001 #2 0.1473 #1 0.2027 #1/0 0.2367 #2/0 0.2781 #3/0 0.3288 #4/0 0.3904 #250 0.4877 #300 0.5581 #350 0.6291 #400 0.6969 #500 0.8316 #600 1.0261 #750 1.2252 ) ;;; conduit usable area (setq c0.5 0.1200 c0.75 0.2100 c1 0.3400 c1.25 0.6000 c1.5 0.8200 c2 1.340 c2.5 1.920 c3 2.950 c3.5 3.960 c4 5.090 c5 8.000 ) ;;; start program (setq phse (getint "\nEnter phase 1 or 3: ")) (if (= phse 1) (setq num 3) ;;else (setq num 4) ) (setq fs (getstring "\nEnter feeder size with # (pound) sign (ex:#4/0 or #250): Feeder: ")) (setq gs (getstring "\nEnter ground size with # (pound) sign (ex:#4/0 or #250): Ground: ")) (if (or (= gs "")(= gs nil)) (setq gs nil) ) (if gs (setq wireArea (+ (* num (eval (read fs))) (eval (read gs)))) ;;else (setq wireArea (* num (eval (read fs)))) ) (cond ((< wireArea c0.5) (setq cc c0.5) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 1/2\" conduit." ) ) ) ((< c0.5 wireArea c0.75) (setq cc c0.75) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 3/4\" conduit." ) ) ) ((< c0.75 wireArea c1) (setq cc c1) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 1\" conduit." ) ) ) ((< c1 wireArea c1.25) (setq cc c1.25) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 1-1/4\" conduit." ) ) ) ((< c1.25 wireArea c1.5) (setq cc c1.5) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 1-1/2\" conduit." ) ) ) ((< c1.5 wireArea c2) (setq cc c2) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 2\" conduit." ) ) ) ((< c2 wireArea c2.5) (setq cc c2.5) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 2-1/2\" conduit." ) ) ) ((< c2.5 wireArea c3) (setq cc c3) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 3\" conduit." ) ) ) ((< c3 wireArea c3.5) (setq cc c3.5) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 3-1/2\" conduit." ) ) ) ((< c3.5 wireArea c4) (setq cc c4) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 4\" conduit." ) ) ) ((< c4 wireArea c5) (setq cc c5) (princ (strcat "\nWire area " (rtos wireArea 2 4) " is < " (rtos cc 2 4) ", use 5\" conduit." ) ) ) (t nil) ) (princ) ) ;end defun ccc
  3. Please help! New to writing LISP's, never used cond before. I'm trying to create a LISP which inserts a block whom's insertion point is determined using a cond statement which evaulates the dwgname variable and returns a value for the insertion coordinates depending on what the dwgname is. If neither are true, it asks for the insertion point to be picked. Please note that stamp.dwg is in my support path so should be able to be located by AutoCAD. Here is what I have... (defun c:insertstamp (x y filename) (setq filename (getvar dwgname)) (stamp:getcoord) (defun stamp:getcoord () (cond ( (= filename A1L.dwg) ((setq x (778.5)) (setq y (204.6716)) (stamp:insert) ) ( (= filename A1P.dwg) ((setq x (531.5)) (setq y (204.6716)) (stamp:insert) ) (t (setq ins (getpoint "Pick Point to Label: ")) (stamp:insert1) ) ) ) (defun stamp:insert () (command _insert stamp.dwg (x,y)) ) (defun stamp:insert1 () (command _insert stamp.dwg ins) ) ) THANKYOU!
  4. Is there a logical reason for using 'if' with 'progn' instead of simply using 'cond'?
  5. I have a routine that I'm working on, which is my first attempt using COND and IF, and I'm running into a problem with how to end the routine. Towards the end, I have (IF (EQ YR "N.F.H.A.") (COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 "") I need it to skip (setq L3 (getstring t "\nType Flood Panel Number: ")) (setq FD (getstring t "\nType Flood Panel Date \"MM/DD/YY\": " )) (SETQ L4 (STRCAT "DATE " FD)) (COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 L3 L4 "")) if the statement is true, otherwise continue on. I'm sure this is an easy fix, I'm just not seeing it. Thanks in advance. here is everything (DEFUN c:LF () (SETQ CL (GETVAR "CLAYER")) (command "layer" "M" "FLOOD" "C" "70" "" "L" "BORDER2" "" "S" "FLOOD" "") (command ".osnap" "NONE") (setq DS (getvar 'dimscale)) (SETQ TW (* DS 1.3)) (SETQ TH (* DS 0.07)) (setq pt1 (getpoint "\nPick Insertion Point: ")) (SETQ L1 (STRCAT "APPROX. LOCATION")) (if (eq (setq ZN (getstring T "\nFlood Zone A, AE or X?: <X> ")) "") (setq zn "X")) (COND ((EQ ZN "A") (setq YR "100")) ((EQ ZN "AE") (SETQ yr "100")) (t (IF (EQ (setq YR (getstring T "\n500 or NFHA? <NFHA> : ")) "") (SETQ YR "N.F.H.A.")))) (COND ((EQ YR "100") (SETQ L2 (STRCAT "ZONE " ZN " " YR "YR"))) ((EQ YR "500") (SETQ L2 (STRCAT "ZONE " ZN " " YR "YR"))) (T (SETQ L2 (STRCAT "ZONE " ZN " " YR )))) ;===============================PAST THIS POINT IS WHERE I'M HAVING THE ISSUE======================================================= (IF (EQ YR "N.F.H.A.") (COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 "") (setq L3 (getstring t "\nType Flood Panel Number: ")) (setq FD (getstring t "\nType Flood Panel Date \"MM/DD/YY\": " )) (SETQ L4 (STRCAT "DATE " FD)) (COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 L3 L4 "")) (COMMAND "CLAYER" CL) )
  6. I want to make the insert option happen by just pressing enter in the following code: (defun c:mak521 () (if (/= (tblsearch "block" "521") nil) (progn (beep) (initget 1 "Yes No INsert") (prompt "\n521 has already been created.") (setq x (getkword "\nInsert 521 at 0,0 or redefine it? [Yes/No] <INsert>: ")) (cond ((= x "Yes") (mak521)) ((= x "No") (exit)) ((= x "INsert") (ins521)) How can I do this?
×
×
  • Create New...