Jump to content

Search the Community

Showing results for tags 'loop'.



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 8 results

  1. Hi all, I'm stuck inside the while loop and can't come out of it. Can someone help me on this (if possible please provide information on why its not closing). This is just a small function of a much larger lisp that I'm playing with and Esc to exit means complete program termination. Here is how I inteded it to be used for. Once user decides to use drawshapes, and if the answer is one of the keyword (eg. Rectangle) then user should be able draw as many rectangles he likes and if Enter is hit it should come back to main menu again ask for keyword to choose (circle or ellipse). Thanks in advance. (defun drawshapes (/ dtype) (setvar "cmdecho" 1) (setq dtype T) (while dtype (initget (+ 2 4) "R P C E") (prompt "\n*** Enter option R, P, C, E ***") (setq dtype (getkword "\nselect your option: Rectangle, Pline, Circle, Ellipse or hit Enter to close:")) (if dtype (cond ( (= dtype "R") (setq loop T) (while loop (command "_.rectang") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ( (= dtype "P") (setq loop T) (while loop (command "_.PLINE") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ( (= dtype "C") (setq loop T) (while loop (command "_.circle") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ( (= dtype "E") (setq loop T) (while loop (command "Ellipse") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ); end cond ); end if ); end while (setvar "cmdecho" 0) );end defun
  2. Hi all, I have a small question here. Is it possible in autoCAD (or via lisp) that when I draw a polyline and when I reach the first point again (from where I have started), the command terminates and give me a closed polyline. And if I dont reach to the first point, it automatically closes to the first point. This is just me make sure I'm not keeping the loop open for hatching? Any help is appriciated.
  3. Hi everyone, Just trying to pass a list of points to a "pline" command. The problem is num of points is initially unknown, though being calculated within a routine. The following code (as smth to start with) evolves known num of points. (defun c:pltest6 () (setq pts (list '(0 0) '(0 10) '(10 10) '(10 20) '(20 20) '(20 30) '(30 30))) (setq ptqty 7) (setq ptnum 0) (command "pline" (car pts) (pt_retr pts) (pt_retr pts) (pt_retr pts) (pt_retr pts) (pt_retr pts) (pt_retr pts) "" ) ) (defun pt_retr (lst) (setq ptnum (1+ ptnum)) (repeat ptnum (setq lst (cdr lst)) ) (setq pt (car lst)) ) Repeat/foreach don't do, 'cause they return the value of the last iteration.. Now my Q is, is it possible to modify the code above to use loop instead of repeat one and the same line (moreover, unknown number of times ), OR some other approach would rather fix the task? Thank you in advance, Dmitro
  4. Dear Experts, I currently obtained a building plan map with rooms, doors, stairs,etc. My task is to extract the doors and tranform it as point. The doors have been represented as a connected arc and two lines. The size of map is fairly large and there is quite a lot of arcs, and so I have to use LISP to automatically extract the arcs based on specific algorithm. My current problems is quite simple: how to loop all drawing entities and extract the type of entities that I want? I want to know the AutoCAD commands, and if your can provide the algorithm, would be very appreciated! Many thanks for your help!
  5. I have to 2 lisp routines that I need to Loop but I need some help. This is just so the user doesn't have to hit enter to return to the command. ; TIES TO BOUNDARY (DEFUN C:DAT () (command ".osnap" "end,per") (COMMAND "LAYER" "S" "BUILDING_LABELS" "") (COMMAND "DIM" "RES" "HOUSE" "EXIT") (COMMAND "DIMALIGNED") (command ".osnap" "NOD,end,INT,CEN,mid") ) ; BUILDING DIMS (DEFUN C:DAH () (command ".osnap" "mid") (COMMAND "LAYER" "S" "BUILDING_LABELS" "") (COMMAND "DIM" "RES" "WALLS" "EXIT") (command ".osnap" "NOD,end,INT,CEN,mid") (COMMAND "DIMALIGNED" "") )
  6. In this portion of a continuing program I'm putting together, a 4' block is inserted at a user point at a defined angle, then it is again inserted but this time 4' away at the same angle so that the two blocks form an 8' line. This is continued until the user stops the program. However, when the second block is inserted, it is rotated correctly but inserted somewhere north of where it is supposed to be. Obviously my polar calc or something is off: (defun c:blockinsert () ; ; ; ;part 5 of overall program ; ; (setq p1 (getpoint "\nSELECT POINT: "));user inputs first point (setq p2 (getpoint "\nSELECT NEXT POINT: "));user inputs second point - for use in part 6 of program ; (setq ang1 (angle p1 p2));get angle from user points (setq angreal (* 180.0 (/ ang1 pi)));convert from radians to degrees ; (setq blockpt "@48<");create a string that puts the next block at 48 inches away at same angle - from first point ; (command "_insert" "I:/documents/pog-panel-4" P1 "1" "1" angreal "1" "category text" "lf");first insertion at first point with two attributes filled ; (setq nextpoint (polar p1 angreal 48));add 4' from p1 at same angle (setq nextp (strcat blockpt angreal));this line is wrong, but I can't figure out how to get the info into the command line... ; (command "_insert" "I:/documents/pog-panel-4" nextp "1" "1" angreal "1" "category text" texttwo) ;insert 4' from last one ; ; ;now I need to add a line that will increase the amount from 4' to 8', ;then to 12', and so on in multiples of 4' - the block is 4' long ;until the user hits escape to stop the block insertions ;maybe use the repeat function? ; );end defun Any ideas on how to correct the insertion and how to create the repeat function and user break?
  7. BrianTFC

    Repeat or loop

    Hi All, I have figured out to combine my three Lisp rputine but it still need works, i need to repeat the last part of the routine until right clicked and i can't figure it out it's driving me nuts. Can some one please help me. Also is there a way to use the the results from the first part of the routine to run the rest of the routine? Thanks, Brian (defun c:test1( / plines ; selection set of polylines ext ; extrnal point dist ; distance to offset poly ; a polyline from plines plist ; the list of poly del ; polyline to delete int ; internal point i) (command "undo" "begin") (princ "select polylines") (setq plines (ssget) i 0 ext (getvar "limmax") dist (getdist (strcat "distance <" (if olddist (rtos olddist) ;use old value as default "") ">"))) (if (not dist) (setq dist olddist)) ;reuse old distance if user press <Enter> (repeat (sslength plines) (setq poly (ssname plines i)) (setq plist (entget poly)) (command "offset" dist poly ext "") (setq del (entlast) int (polar (cdr (assoc 10 (entget del))) (angle (cdr (assoc 10 (entget del))) (cdr (assoc 10 plist))) (* 2 (distance (cdr (assoc 10 plist)) (cdr (assoc 10 (entget del))))))) (command "offset" dist poly int "") (command "_.change" (entlast) "" "_p" "_la" (getvar 'clayer) "") (entdel del) (setq i (1+ i))) (command "undo" "end") (setq olddist dist) ;preserve current distance for next run (vl-load-com) (princ "\n>>> Select lines to extend/reduce <<< ") (if (and (setq lSet (ssget '((0 . "LINE")))); (setq lDel (getreal "\nSpecify : ")) ); end and (progn (initget 1 "Positive Negative Both") (setq doMode (getkword "\nSpecify direction [Positive/Negative/Both]: ") objLst(mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex lSet))))); end setq (vla-StartUndoMark (setq actDoc (vla-get-ActiveDocument (vlax-get-acad-object)))); end vla-StartUndoMark (if(member doMode '("Negative" "Both")) (foreach ln objLst (vlax-put ln 'startpoint (polar (vlax-get ln 'startpoint) (vlax-get ln 'angle)(- lDel))); end vlax-put ); end foreach ); end if (if(member doMode '("Positive" "Both")) (foreach ln objLst (vlax-put ln 'endpoint (polar (vlax-get ln 'endpoint) (vlax-get ln 'angle)lDel)) ); end foreach ); end if (vla-EndUndoMark actDoc) ); end progn ); end if (vl-load-com) (if (and (setq cEnt (car (entsel "\nSelect Object: "))) (member (cdr (assoc 0 (entget cEnt))) '("LWPOLYLINE" "POLYLINE" "LINE"))) (progn (setq tStr (strcat "1@" (rtos (- (vla-get-length (vlax-ename->vla-object cEnt)) 5.38)) (strcat "''")) tBox (textbox (list (cons 1 tStr) (cons 40 (getvar "TEXTSIZE")))) tHgt (- (cadadr tBox) (cadar tBox)) twid (- (caadr tBox) (caar tBox))) (princ "\nPosition Text...") (while (eq 5 (car (setq gr (grread t 5 0)))) (redraw) (if (listp (setq sPt (cadr gr))) (progn (setq cPt (vlax-curve-getClosestPointto cEnt sPt) lAng (angle cPt sPt) bpt (polar cPt lAng (/ (getvar "TEXTSIZE") 2.)) tpt (polar bpt lAng tHgt) mPt (polar bPt lAng (/ tHgt 2.)) pt1 (polar bpt (+ lAng (/ pi 2.)) (/ tWid 2.)) pt2 (polar bPt (- lAng (/ pi 2.)) (/ tWid 2.)) pt3 (polar tpt (+ lAng (/ pi 2.)) (/ tWid 2.)) pt4 (polar tPt (- lAng (/ pi 2.)) (/ tWid 2.))) (grvecs (list -3 pt1 pt2 pt3 pt4 pt1 pt3 pt2 pt4))))) (if (eq 3 (car gr)) (progn (setq lAng (- lAng (/ pi 2.))) (cond ((and (> lAng (/ pi 2)) (<= lAng pi)) (setq lAng (- lAng pi))) ((and (> lAng pi) (<= lAng (/ (* 3 pi) 2))) (setq lAng (+ lAng pi)))) (Make_Text mPt tStr lAng)))) (princ "\n<!> Incorrect Selection <!>")) (redraw) (princ)) (defun Make_Text (pt val rot) (entmake (list (cons 0 "TEXT") (cons 8 (getvar "CLAYER")) (cons 62 1) (cons 10 pt) (cons 40 (getvar "TEXTSIZE")) (cons 1 val) (cons 50 rot) (cons 7 (getvar "TEXTSTYLE")) (cons 71 0) (cons 72 1) (cons 73 2) (cons 11 pt))) ) (princ)
  8. I am new to this forum, looking for some help on a lisp routine been working on. The routine works except. My goal is to execute the routine in a loop, allowing me to continue to pick and change until "enter" key in pressed, without any errors being printed in the command line. Right now if I press the "ECS" key it exits the routine and settings are returned, i.e. osmode reset to previous settings. If I press "ENTER" it exits with an error message. Here is the routine (defun c:bc90 ( / se sp point snap echo olderr) (setq snap (getvar "osmode") echo (getvar "cmdecho") olderr *error* *error* break_error ) (setvar "cmdecho" 0) (progn (setvar "osmode" 32) (while (null (nentselp (setq point (getpoint "\nSelect Breaking Point (or ENTER when done): "))) ) ) (setvar "osmode" 512) (while (not se) (setq sp (cadr (setq se (entsel "\nSelect Line to Change to Hidden: ")))) ) (setvar "osmode" 0) (command "break" se "f" point "@") (command "change" sp "" "p" "c" "9" "lt" "hidden" "") (princ) ) (setvar "osmode" snap) (setvar "cmdecho" echo) (setq *error* olderr) (princ) ) (defun break_error (msg) (princ (strcat "\nError: " msg)) (setvar "osmode" snap) (setvar "cmdecho" echo) (princ ) ) The progn line was added in early failed attempts at looping. I am trying to limit the number of keyboard inputs so I do not want "Press [Y] to continue or [Exit]" type lines in the routine. Just a simple "ENTER" to exit. If possible. any help would be nice, thanks
×
×
  • Create New...