Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/22/2022 in all areas

  1. Is it not a DRAWORDER question, it does what you wantt like move to top.
    1 point
  2. Sorry Steve it did copy fine, now to to try it with my objects
    1 point
  3. It appears to be the polar function, this works: (setq mpt (mapcar '/ (mapcar '+ ll ur) '(2 2 2)))
    1 point
  4. Change this: (list (max (last ll) (last ur))) To this: (list (+ 0.01 (max (last ll) (last ur))))
    1 point
  5. @Emmanuel Delay your code places the dimension on the opposite side of the line when ar is to the left of al and the aligned dimension goes from left to right. Here's a before and after shot. I avoid using angles although sometimes it is easier. Here's a modified version of your code using vectors. (defun deg2rad (ang / ) (/ (* PI ang) 180.0) ) (defun rad2deg ( ang / ) (/ (* 180.0 ang) PI) ) ;; midpoint of 2 given points (defun mid ( pt1 pt2 / ) (mapcar '(lambda (x y) (+ (* 0.5 x) (* 0.5 y))) pt1 pt2 ) ) ;;; Calculate unit vector of vector a (defun uvec (a / d) (setq d (distance '(0 0 0) a) a (mapcar '/ a (list d d d)) ) ) ; Compute the dot product of 2 vectors a and b (defun dot ( a b / dd) (setq dd (mapcar '* a b)) (setq dd (+ (nth 0 dd) (nth 1 dd) (nth 2 dd))) ) ;end of dot (defun c:test2 ( / sel ent txp al ar mp uALR s txpp uvt tp ) (princ "\nDistance DIM: ") (setq dist (getreal)) (while (setq sel (entsel "\nSelect DIM: ")) (setq ent (car sel )) (setq txp (cdr (assoc 10 (entget ent)))) (setq al (cdr (assoc 13 (entget ent)))) (setq ar (cdr (assoc 14 (entget ent)))) ;;; (setq ang1 (angle al ar)) ;;; (setq mp (mid al ar)) ;;; ;;; (setq ang2 (angle mp txp)) ;;; ;;; (if (< ang1 ang2) ;;; (setq tp (polar mp (+ ang1 (deg2rad 90.0)) dist)) ;;; (setq tp (polar mp (- ang1 (deg2rad 90.0)) dist)) ;;; ) (setq mp (mapcar '/ (mapcar '+ al ar) '(2. 2. 2.) ) ) ; uALR = unit vector from al to ar (setq uALR (uvec (mapcar '- ar al))) (setq s (dot uALR (mapcar '- txp al))) ; txpp = projection of txp onto the line (setq txpp (mapcar '+ al (mapcar '* uALR (list s s s))) ) (setq uvt (uvec (mapcar '- txp txpp))) (setq tp (mapcar '+ mp (mapcar '* uvt (list dist dist dist)))) (entmod (subst (cons 10 tp) (assoc 10 (entget ent)) (entget ent)) ) (entmod (subst (cons 11 tp) (assoc 11 (entget ent)) (entget ent)) ) ) (princ) )
    1 point
  6. Try this. Certainly not completely as it should be, but it's a start. So ... DXF 13 and 14 are the points to be measured. I measure the midppoint between those points, then DXF 10 and 11 are set 30 units (the user sets this) from that midpoint, perpendicular to the line 13 - 14. So for the moment it's for aligned dimentions, it won't work in all conditions. Command DFD (defun deg2rad (ang / ) (/ (* PI ang) 180.0) ) (defun rad2deg ( ang / ) (/ (* 180.0 ang) PI) ) ;; midpoint of 2 given points (defun mid ( pt1 pt2 / ) (mapcar '(lambda (x y) (+ (* 0.5 x) (* 0.5 y))) pt1 pt2 ) ) (defun c:dfd ( / dist sel ent al ar ang1 ang2 mp tp txp) (princ "\nDistance DIM: ") (setq dist (getreal)) (while (setq sel (entsel "\nSelect DIM: ")) (setq ent (car sel )) (setq txp (cdr (assoc 10 (entget ent)))) (setq al (cdr (assoc 13 (entget ent)))) (setq ar (cdr (assoc 14 (entget ent)))) (setq ang1 (angle al ar)) (setq mp (mid al ar)) (setq ang2 (angle mp txp)) (if (< ang1 ang2) (setq tp (polar mp (+ ang1 (deg2rad 90.0)) dist)) (setq tp (polar mp (- ang1 (deg2rad 90.0)) dist)) ) (entmod (subst (cons 10 tp) (assoc 10 (entget ent)) (entget ent) )) (entmod (subst (cons 11 tp) (assoc 11 (entget ent)) (entget ent) )) ) (princ) )
    1 point
  7. Nice.... The reason I asked was that I haven't seen an effective way to have an open drawing interrogate or modify another open drawing. You can use a script on any closed drawings (there are some examples out there), some like scriptwriter, Lee Macs. or Jeff Saunters will do it all in the background and you can write a script to open, operate on and close a drawing - and here you can use any LISP commands you want, but I have struggled to find a way to do that on an open drawing by LISP - the problem being that LISPS run on the drawing that started them off, and once you move from that the LISP won't keep running in the next drawing. Depending what you want to do once you have the title block info I would be tempted to do it all on closed drawings, select the ones you want and do it all with a script (scriptwriter, Lee Mac, Jeff Saunter, or mine (below) should all be able to do that)
    1 point
  8. I quickly modified the code from Alan to work in decimal units and output the result in meters squared. ; CREATED BY: alan thompson 11.28.07 ; MODIFIED BY: alan thompson 12.19.07 (MTEXT instead of DTEXT, lot numbering works better, etc.) ; MODIFIED BY: 3dwannab 18.01.22 ; Just modified slightly to work with decimals as units. ; Asks user for the height of the MTEXT. ; Outputs '95.78m²' to the MTEXT object and 'Area in m²: 95.78' to the command line. (defun c:Area_Get_Picked( / *error* areacmdstr areainmmval mtextcontents pt ) (defun *error* (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>\n")) ) (setvar 'cmdecho var_cmdecho) (setvar 'osmode var_osmode) ) (setq var_cmdecho (getvar "cmdecho")) (setq var_osmode (getvar "osmode")) (setvar 'cmdecho 0) (setvar 'osmode 0) (graphscr) (setq pt (getpoint "Click internal point: ")) (command "-hatch" pt "") (command "area" "o" "L") (setq areainmmval (rtos (/ (getvar "area") 1e6) 2 2)) ; How to get m² from mm² in area in AutoCAD. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/mm2-to-m2-soma-areas-m2-lsp-and-mm-to-m-soma-perimetros-lsp/m-p/5963137/highlight/true#M337718 (setq areacmdstr (strcat "\n\nArea in m\U+00B2: " areainmmval)) (command "erase" "L" "") (setq mtextcontents (strcat areainmmval "m\U+00B2")) (princ (strcat areacmdstr)) (command "._MTEXT" pt "_J" "_MC" "C" "N" "H" pause pt mtextcontents "") (setvar "cmdecho" 1) (setvar 'cmdecho var_cmdecho) (setvar 'osmode var_osmode) (*error* nil) (princ) )
    1 point
×
×
  • Create New...