Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/07/2022 in all areas

  1. I assume your goal is to round up to a multiple of 5. Rem is helpful in rounding up. For example, (defun c:RoundUp ( / a b ) (setq a (getreal "\nEnter number: ")) (setq b ( + 5 (- a (rem a 5.)))) (princ "\Rounded up value = ") (princ b) (princ) )
    2 points
  2. I wonder if this will help, http://www.lee-mac.com/round.html looking at 'round up to the next multiple'?
    1 point
  3. This worked! Thank you so much! I was working through this thread in order of easiest to hardest. I tried swapping the order of commands (didn't work) and the alluded to (vla-sendcommand) function (still led to the same problem). However (eval (list ( /string of command name incl parentheses /))) works perfectly. This is my initial time using eval in this way, and it's quite awesome - it's the first time I've felt lisp can do something better than another language. This has been a great learning experience.
    1 point
  4. You're welcome. Just add the entity name to the selection set as follows. (0 . "*TEXT,INSERT,LWPOLYLINE")
    1 point
  5. term_dialog in itself isn't necessarily a problem but its a little crude , like a dragon in a porcelain cabinet ... it better should only be used in your error handling routine as a final act of desperation. You cannot run commands while a dialog is active , well , not normal autocad commands anyway that involve screen interaction. There is a way around this using vla-commands but thats beyond the scope of this thread.
    1 point
  6. First a comment that in my LISPs containing a DCL I have them (action_tile "Build" "(execute) (term_dialogue)") not sure if the order makes a difference. Here is one thing that I have used (action_tile "build" "(setq MyAction \"Evaluate\")(done_dialog)") ... ... (eval (list (read "MyAction"))) This was from a DCL box where the user can choose what to run, their selected LISP is saved as a variable and then run later
    1 point
  7. You can do that and more with Sheet Sets. SHEETS HAPPEN! Introduction to the Sheet Set Manager https://forums.autodesk.com/autodesk/attachments/autodesk/66/257215/1/Sheets_Happen.pdf
    1 point
  8. In your action_tile you could put something like (action_tile "build" "(setq to-do \"insert\")(done_dialog)") at the very last line(s) of your routine you could then put something like : ...your code (cond ((eq to-do "insert")(go-insert-yourself)) ((eq to-do "script")(go-script-yourself)) (t (princ ""\nComputer says bye")) );end con ); end of your function
    1 point
  9. Hi Here is a lisp from my archive Works in WCS and parallel UCS. Z rotation allowed, but not 3D rotation. Text is inserted in both ends of each line Text height is 1% of grid spacing. ;Stefan M. 12.02.2018 (defun C:SURVGRID ( / *error* acdoc acobj dimzin GET_POINTS REMOVE_DUPLICATES SEL_OBJ ROT ADD_GRID e dir msg o a pts a1 a2 x1 x2 y1 y2 p1 p2 int ) (vl-load-com) (setq acobj (vlax-get-acad-object) acdoc (vla-get-activedocument acobj) ) (if (= (logand 8 (getvar 'undoctl))) (vla-endundomark acdoc)) (setq dimzin (getvar 'dimzin)) (setvar 'dimzin 8) (defun *error* (msg) (and msg (not (wcmatch (strcase msg) "*EXIT*,*CANCEL*,*ABORT*")) (princ (strcat "\nEroare: " msg)) ) (setvar 'dimzin dimzin) (if (= (logand 8 (getvar 'undoctl))) (vla-endundomark acdoc)) (princ) ) ;Get list of polyline vertexes. ;Bulged segments are refined with points at max. 5° apart (defun get_points (e / a b p q n d l a1) (setq e (vlax-ename->vla-object e) a (vlax-curve-getstartparam e) b (vlax-curve-getendparam e) ) (while (< a b) (setq p (vlax-curve-getpointatparam e a) q (atan (abs (vla-getbulge e a))) n (fix (/ (* 80 q) pi)) a1 a ) (if (not (equal p (car l) 1e-8)) (setq l (cons p l))) (if (> n 0) (repeat (1- n) (setq a1 (+ a1 (/ 1.0 n)) p (vlax-curve-getpointatparam e a1) ) (if (not (equal p (car l) 1e-8)) (setq l (cons p l))) ) ) (setq a (1+ a)) ) l ) (defun remove_duplicates (l / r) (while l (if (not (equal (car l) (car r) 1e-8)) (setq r (cons (car l) r)) ) (setq l (cdr l)) ) r ) (defun sel_obj (msg etype / e) (setvar 'errno 0) (setq e (car (entsel msg))) (cond ((= (getvar 'errno) 7) (princ "\nNothing selected. Try again.") (sel_obj msg etype) ) ((not e) nil) ((wcmatch (cdr (assoc 0 (entget e))) etype) e) (t (princ "\nInvalid object. Try again.") (sel_obj msg etype) ) ) ) (defun rot (p a) (list (- (* (car p) (cos a)) (* (cadr p) (sin a))) (+ (* (car p) (sin a)) (* (cadr p) (cos a))) ) ) (defun add_grid (p1 p2 str a) (entmakex (list '(0 . "TEXT") '(8 . "Grid") (cons 10 (mapcar '+ o (rot (polar p1 (* 0.25 pi) (* (sqrt 2) 0.01 *dist*)) a))) (cons 40 (* 0.02 *dist*)) (cons 1 str) (cons 50 a) (assoc 41 (tblsearch "style" (getvar 'textstyle))) (cons 7 (getvar 'textstyle)) ) ) (entmakex (list '(0 . "TEXT") '(8 . "Grid") '(10 0.0 0.0 0.0) (cons 40 (* 0.02 *dist*)) (cons 1 str) (cons 50 a) (assoc 41 (tblsearch "style" (getvar 'textstyle))) (cons 7 (getvar 'textstyle)) '(72 . 2) (cons 11 (mapcar '+ o (rot (polar p2 (* 0.75 pi) (* (sqrt 2) 0.01 *dist*)) a))) '(73 . 0) ) ) (entmakex (list '(0 . "LINE") '(8 . "Grid") (cons 10 (mapcar '+ o (rot p1 a))) (cons 11 (mapcar '+ o (rot p2 a))) ) ) ) (or *dist* (setq *dist* 100.0)) (if (and (setq e (sel_obj "\nSelect polyline: " "*POLYLINE")) (progn (setq dir (if (zerop (getvar 'worlducs)) "Ucs" "Wcs")) (initget "Wcs Ucs") (setq dir (cond ((getkword (strcat "\nSpecify origin [Wcs/Ucs] <" dir ">: "))) (dir) ) ) ) (setq msg "\nUCS is not parallel to WCS.") (or (eq dir "Wcs") (and (equal (caddr (getvar 'ucsxdir)) 0.0 1e-8) (equal (caddr (getvar 'ucsydir)) 0.0 1e-8) ) ) (if (eq dir "Wcs") (setq o '(0.0 0.0 0.0) a 0.0 ) (setq o (getvar 'ucsorg) a (angle '(0.0 0.0 0.0) (getvar 'ucsxdir)) ) ) (setq pts (remove_duplicates ( (lambda (l) (cons (last l) l)) (get_points e) ) ) ) (setq msg "\nPolyline is not parallel to WCS.") ( (lambda (l) (vl-every '(lambda (x) (equal (car l) x 1e-8)) l) ) (mapcar 'caddr pts) ) (setq pts (mapcar '(lambda (p) (rot (mapcar '- p o) (- a)) ) pts ) ) (setq *dist* (cond ((getdist (strcat "\nSpecify grid distance <" (rtos *dist*) ">: "))) (*dist*) ) ) ) (foreach u (list nil (/ pi -2.0)) (if u (setq pts (mapcar '(lambda (p) (rot p u)) pts)) (setq u 0.0) ) (mapcar '(lambda (p f) (set p (apply 'mapcar (cons f pts)))) '(a1 a2) '(min max) ) (setq x1 (- (car a1) *dist*) y1 (* *dist* (fix (/ (cadr a1) *dist*))) x2 (+ (car a2) *dist*) y2 (* *dist* (1+ (fix (/ (cadr a2) *dist*)))) ) (while (<= y1 y2) (setq p1 (list x1 y1) p2 (list x2 y1) ) (if (and (setq int (vl-remove nil (mapcar '(lambda (p3 p4) (inters p1 p2 p3 p4 T)) pts (cdr pts)))) (setq int (vl-sort int '(lambda (a b) (> (car a) (car b))))) (setq int (remove_duplicates int)) (> (length int) 1) ) (while (cadr int) (add_grid (car int) (cadr int) (if (zerop u) (strcat "N " (rtos y1 2 3)) (strcat "E " (rtos (- y1) 2 3)) ) (- a u) ) (setq int (cddr int)) ) ) (setq y1 (+ y1 *dist*)) ) ) (if msg (princ msg)) ) (*error* nil) (princ) )
    1 point
  10. My experience has been that editing the geometry or grips or segments of an alignment will only get you so far. In most cases it's less of a headache to draw the darn thing over from scratch. If you have no choice about keeping the alignments, whenever you move the beginning station, you may have to add a station equation. Sorry, I have no practical experience with those.
    1 point
  11. Hello, When having this problem first type in command line dwg units. choose the one you are using on the last 3 options choose No.
    1 point
×
×
  • Create New...