HOang6893 Posted October 3, 2023 Posted October 3, 2023 Hello experts. I'm having problems with the lisp I'm using. Specifically: - When I set dim style > round off = 10 the lisp I am using still reports the dim values with round off = 0. Can experts help me fix this error? Thank you very much ! ccd.lsp Copy dim.dwg Quote
hosneyalaa Posted October 3, 2023 Posted October 3, 2023 hi after get property round off from DIMENSION using http://lee-mac.com/round.html Quote
Emmanuel Delay Posted October 3, 2023 Posted October 3, 2023 Like this? (defun c:ccd (/ gtt dt sdt ent id str) (setq dt (ssget '((0 . "DIMENSION"))) sdt (sslength dt) id 0 gtt 0 str "=" ) (repeat sdt (setq ent (ssname dt id) id (1+ id) gtt (+ gtt (gt1 ent) ) str (strcat str (Rtos (gt1 ent) 2 0 ) "+") ) ) (Lisped (substr str 1 (1- (strlen str)))) (princ gtt) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;; (defun gt1 (ent / so ro) ;; roundoff (setq ro (nth 0 (ParseIt (cdr (assoc 3 (entget ent)))))) (if (wcmatch (cdr (assoc 1 (entget ent))) "") (setq so (LM:roundm (cdr (assoc 42 (entget ent))) ro)) ;; round the value to ro (setq so (atof (cdr (assoc 1 (entget ent))))) ) ) ;; http://www.lee-mac.com/round.html ;; Round Multiple - Lee Mac ;; Rounds 'n' to the nearest multiple of 'm' (defun LM:roundm ( n m ) (* m (fix ((if (minusp n) - +) (/ n (float m)) 0.5))) ) ;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/extracting-numeric-values-on-a-string/td-p/784014 (defun ParseIt (str) (read (vl-list->string (append '(40) ; "(". (mapcar '(lambda (int) (if (or (= 46 int) (<= 48 int 57)) int 32)) (vl-string->list str) ) '(41) ; ")". ) ) ) ) 1 Quote
HOang6893 Posted October 3, 2023 Author Posted October 3, 2023 Thanks Emmanuel Delay. Your Lisp works exactly as I wanted. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.