Hi, I'm looking for help with an AutoCAD LISP routine that does the following:
Any help would be greatly appreciated!
Solved! Go to Solution.
Solved by ec-cad. Go to Solution.
Solved by komondormrex. Go to Solution.
Solved by ec-cad. Go to Solution.
Solved by pbejse. Go to Solution.
@Temssi.d wrote:
- The routine should loop continuously until manually terminated.
Q&D
(defun c:Demo ( / theYPoint )
(while
(progn
(command "_insert" "S-MIF3" pause)
(while (= 1 (getvar "cmdactive"))(command ""))
(setq theYPoint (cadr (Getvar 'LastPoint)))
(princ "\nPressed ESC to terminate")
)
(setpropertyvalue (entlast) "MIFLAS"
(strcat (if (minusp theYPoint) "" "+") (rtos theYPoint 2 2)))
)(princ)
)
HTH
wow great thank you very much!!
Is it possible to make a small correction to the measurement output?
The measurement is in centimeters and should be converted to meters with two digits after the point including zeros if necessary.
123 -> +1.23
60 -> +0.60
300 ->+3.00
and so'..
Not tested, but try this one little change.
ECCAD
(defun c:Demo ( / theYPoint )
(while
(progn
(command "_insert" "S-MIF3" pause)
(while (= 1 (getvar "cmdactive"))(command ""))
(setq theYPoint (/ (cadr (Getvar 'LastPoint)) 100.00)); <------ replace this line
(princ "\nPressed ESC to terminate")
)
(setpropertyvalue (entlast) "MIFLAS"
(strcat (if (minusp theYPoint) "" "+") (rtos theYPoint 2 2)))
)(princ)
)
Thanks!🙏
Dividing by 100 is really the right way. The difficulty is with the zeros.
300 becomes 3
320 becomes 3.2
...it's very close but not exactly 🙂
hey there,
the one dynamic
(defun c:e1 (/ continue insert grread_data insertion)
(defun add_plus (string)
(if (= 'int (type (read string)))
(if (/= "-" (substr string 1 1)) (strcat "+" string ".00") (strcat string ".00"))
(if (/= "-" (substr string 1 1)) (strcat "+" string) string)
)
)
(defun move_insert (insert insertion)
(vla-move insert (vla-get-insertionpoint insert) (vlax-3d-point insertion))
(setpropertyvalue (vlax-vla-object->ename insert) "MIFLAS" (add_plus (rtos (/ (cadr (vlax-get insert 'insertionpoint)) 100.0) 2 2)))
)
(setq continue t)
(while (and continue
(null (prompt "\rLeft click to set point, right click to set precise point, Ecs to cancel"))
(setq insert (vla-insertblock (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-3d-point (setq insertion (cadr (grread t)))) "s-mif3" 1 1 1 0
)
)
)
(while (and (null (vl-catch-all-error-p (setq grread_data (vl-catch-all-apply 'grread (list t 15 0)))))
(not (member (car grread_data) '(3 11 25)))
)
(move_insert insert (cadr grread_data))
(setq insertion (cadr grread_data))
)
(cond
((vl-catch-all-error-p grread_data)
(vla-erase insert)
(setq continue nil)
)
((member (car grread_data) '(11 25))
(setq insertion (getpoint insertion "\nPick point to place block at: "))
(move_insert insert insertion)
)
)
)
(princ)
)
@Temssi.d hi,
i liked 👍 that you exactly know how this tool should be work but this arise some question in my mind:
a. "S-MIF3" to work in cm units so and you need to divide "miflas" value by 100
ok you notice this and it's corrected 😀
b. there is a need to cover +/- 0.00
c. do you plan to lay all sections and elevations on same row? cause if you lay a section B-B above section A-A, the
"miflas" value would not fit or you could create each section\elevation specific ucs?
Sorry for late posting. Original had 1000.00 DAH, should have been 100.0
And for adjusting the digits to 2 places, try this new version.
Cheers
(defun c:Demo ( / theYPoint )
(while
(progn
(command "_insert" "S-MIF3" pause)
(while (= 1 (getvar "cmdactive"))(command ""))
(setq theYPoint (/ (cadr (Getvar 'LastPoint)) 100.00)); <------ replace this line
(princ "\nPressed ESC to terminate")
)
(setq value (strcat (if (minusp theYPoint) "" "+") (rtos theYPoint 2 2)))
;; added to set 0 on end
(setq chk (substr value (- (strlen value) 1) 1)); check 2nd to last character
(if (= chk ".")(setq value (strcat value "0"))); add a 0
(if (or (= value "+0")(= value "-0"))
(setq value "+/-0.00")
); if
;; end of added
(setpropertyvalue (entlast) "MIFLAS" value)
)
(princ)
)
ECCAD
Can't find what you're looking for? Ask the community or share your knowledge.