Jump to content

Leaderboard

Popular Content

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

  1. You could always try a while loop and a counter - I tend to go that way by default but that's just me. Added some 'princ' to tell you how it is going on as an example below.. overkill but sometimes seeing it all written out helps (princ "\nMy List: ") (princ list) ;;Gives you the full list so you can see it (setq acount 0) (while (< acount (length list)) (setq pt (nth acount list)) (princ "\n - count: ") (princ acount) ; Position in list (princ " : pt: " ; (princ pt) ; point (command "copy" pt "" basept despt) (princ "COPY OK") ; Copied OK (setq acount (+ acount 1)) ) ; end while (princ "All Copied") If it struggles at that post what the princ statements say... should be a clue in them
    1 point
  2. @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
  3. (defun C:SVLAY(/) (HB:SV_LAYOUT) );end defun (defun HB:SV_LAYOUT ( / DWG NDWG LST NLST L NL DL DL_LST) (foreach DWG (HB:SV_DWG_LIST) (setq NDWG DWG) (setq LST (getdrawinglayouts NDWG)) (setq NLST (vl-remove (nth 0 LST) LST)) (foreach L NLST (setq NL L) (setq DL (list NDWG NL)) (setq DL_LST (cons DL DL_LST)) );end foreach );end foreach DL_LST );end defun HB:SV_LAYOUT (defun HB:SV_DWG_LIST ( / obj ACdocuments doccount i pathlist item path) (vl-load-com) (setq obj (vlax-get-acad-object)) (setq ACdocuments (vla-get-documents obj)) (setq doccount (vla-get-count acdocuments)) (setq i 0) (setq pathlist'()) (repeat doccount (setq item (vla-item acdocuments i)) (setq path (vla-get-fullname item)) (if (/= "" path) (setq pathlist (cons path pathlist)) );end if (setq i (+ i 1)) );end repeat pathlist );end defun HB:SV_DWG_LIST (defun getdrawinglayouts ( dwg / doc idx rtn ) (if (setq doc (LM:getdocumentobject dwg)) (progn (vlax-for lyt (vla-get-layouts doc) (setq rtn (cons (vla-get-name lyt) rtn) idx (cons (vla-get-taborder lyt) idx) ) ) (vlax-release-object doc) (mapcar '(lambda ( n ) (nth n rtn)) (vl-sort-i idx '<)) ) ) ) (defun LM:getdocumentobject ( dwg / app dbx dwl err vrs ) (cond ( (not (setq dwg (findfile dwg))) nil) ( (cdr (assoc (strcase dwg) (vlax-for doc (vla-get-documents (setq app (vlax-get-acad-object))) (setq dwl (cons (cons (strcase (vla-get-fullname doc)) doc) dwl)) ) ) ) ) ( (progn (setq dbx (vl-catch-all-apply 'vla-getinterfaceobject (list app (if (< (setq vrs (atoi (getvar 'acadver))) 16) "objectdbx.axdbdocument" (strcat "objectdbx.axdbdocument." (itoa vrs)) ) ) ) ) (or (null dbx) (vl-catch-all-error-p dbx)) ) (prompt "\nUnable to interface with ObjectDBX.") ) ( (vl-catch-all-error-p (setq err (vl-catch-all-apply 'vla-open (list dbx dwg)))) (prompt (strcat "\n" (vl-catch-all-error-message err))) ) ( dbx ) ) ) (vl-load-com) (princ)
    1 point
  4. I Usually just use ssget to get ent name of stuff. (if (setq SS (ssget "X" '((0 . "INSERT") (2 . "SAL-TEKENBLAD_TITELBLOK")))) (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) This will get you a selection set of all SAL-TEKENBLAD_TITELBLOK in the drawing. If you want to get a particular titleblock you can further limit it down to a specific layout. by adding (410 . "Tab Name") (setq SS (ssget "X" '((0 . "INSERT") (2 . "SAL-TEKENBLAD_TITELBLOK") (410 . "Sheet 3"))))
    1 point
  5. Aww, I was looking for some good magic from you here! It would be a useful LISP to keep drawing output consistent. I had a very quick look and it appears that the text position is controlled by DXF codes 10 and 11, you might be able to work something out with them and some maths maybe, though I haven't got chance today to see what you can do
    1 point
  6. Hi, This line ask user to select a viewport on screen. If you already have the viewport (iterate through your viewport selection set), you got to skip this step, and put your viewport directly in (if (and (= (getvar "cmdactive") 0) (/= (setq ss (ssget ":E:S" '((0 . "VIEWPORT")))) nil) ) Replace ;replace this: (setq ent (ssname ss 0)) ;with this: (setq ent yourviewporthere) Also the vpsel function pass the result to the grip selection, then nullify the result at the end (setq ss nil ss1 nil) While you want to get the result, so, you got to comment out that line, and take the ss1 result out of the function, merge it to your rrr selection
    1 point
  7. I also don't download any compiled code, lisp and dcl only.
    1 point
  8. Try this (defun c:ndim-value (/ p1 p2 p3 Udist) (setq udist (getreal "\nOffset Distance :")) (setq p1 (getpoint "\n Specify first extension line origin :")) (setq p2 (getpoint "\n Specify first extension line origin :")) (setq P3 (polar P2 (+ (angle p1 p2)(/ pi 2)) udist)) (command "_.dimaligned" "_non" p1 "_non" p2 "_m" "" P3) (while (setq p1 (getpoint "\n Specify first extension line origin :")) (setq p2 (getpoint "\n Specify first extension line origin :")) (setq P3 (polar P2 (+ (angle p1 p2)(/ pi 2)) udist)) (command "_.dimaligned" "_non" p1 "_non" p2 "_m" "" P3) ) (princ) ) This works fine if there are no objects near where the dimension is placed because the osnaps (osmode) is not changed. type ndim-value to start just input the offset distance then start clicking on the objects to dimension enter to end. Its a bit rough and works for aligned dimensions linear change to dimlinear If you want the osnaps built in give me a little time just let me know
    1 point
×
×
  • Create New...