Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/23/2025 in all areas

  1. Only one DIMALIGNED call is required, e.g.: (defun c:mydimalign ( / e p x ) (if (and (setq e (car (entsel))) (= "LWPOLYLINE" (cdr (assoc 0 (setq x (entget e))))) ) (foreach g x (cond ( (/= 10 (car g))) ( p (command "_.dimaligned" p (setq p (cdr g)) "@5<180")) ( (setq p (cdr g))) ) ) ) (princ) )
    2 points
  2. Even though the codes should work but would draw them vertically.
    1 point
  3. By the way, Tharwat: I can't get your code to work Could it be my problem?
    1 point
  4. I see there is consensus on the idea of getting each pair of points by executing 'foreach' twice In my case, I'm going to insist on getting it in just 1, reducing the executed code as much as possible (or at least that's what I think) and preserving the original code as much as possible. I suppose there will be differences of opinion on this (defun c:myDimAlign (/ bm pline sublist pt1 pt2) (if (and (setq pline (car (entsel "\nSelect any LWpolyline..."))) (= (cdr (assoc 0 (setq bm (entget pline)))) "LWPOLYLINE"); Check if the entity type is LWPOLYLINE ) (progn (command "_.chprop" pline "" "_lw" "10.00" "") (foreach sublist bm (if (= (car sublist) 10) ; Look for vertex points (coded as 10). (if pt2 (command "DIMALIGNED" (setq pt1 pt2) (setq pt2 (cdr sublist)) "@5<180") (if pt1 (command "DIMALIGNED" pt1 (setq pt2 (cdr sublist)) "@5<180") (setq pt1 (cdr sublist)) ) ) ; end progn ) ; end if ) ; end foreach ) ; end progn ) )
    1 point
  5. Based on your way of processing, here is what I think is what you are after. (if (and (setq s (car (entsel "\nSelect LWpolyline : "))) (= (cdr (assoc 0 (setq bm (entget s)))) "LWPOLYLINE") ) (progn (foreach grp bm (if (= (car grp) 10) (setq pts (cons (cdr grp) pts)) ) ) (entmod (append bm '((370 . 10)))) (setq p1 (car pts)) (foreach pt (cdr pts) (command "DIMALIGNED" "_non" p1 "_non" pt "@0.35<180") (setq p1 pt) ) ) )
    1 point
  6. This is what I use and I am pretty sure it was posted by Lee-mac many years ago. (setq plent (entsel "\nPick pline ")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) so if you want pt1 pt2 (setq pt1 (car co-ord) pt2 (cadr co-ord)) You can also use the Vl functions getstartpoint & getendpoint
    1 point
  7. Steps as Lee Mac Suggests - Use ForEach to create a list of points (assoc 10) - End ForEach - Loop through list of points (n-1) times where n is the list length - Put in your dimension - End Loop Often there is a function out there that can 'plug and play' into a routine... below is a subfunction massoc which I find really handy, often using the 2nd option in the 2nd post... 'Key' in your case will be 10 lst in your case will be pdb (though you might be able to also use (entget bm) The return is a list of all the keys, in your case the points, I think in the format (10 pt-X pt-Y pt-Z), so (CADR... to get the points only.
    1 point
  8. This give a point at min z on 3Dpolyline. (vl-load-com) (defun c:min_z ( / js obj ename pr pt lst_pt lst_z id_seg nw_pt) (princ "\nSelect 3DPolylines: ") (while (null (setq js (ssget '((0 . "POLYLINE") (-4 . "&") (70 . 8))))) (princ "\nObjects not valid!") ) (repeat (setq n (sslength js)) (setq obj (ssname js (setq n (1- n))) ename (vlax-ename->vla-object obj) pr -1 lst_pt nil ) (repeat (if (zerop (vlax-get ename 'Closed)) (1+ (fix (vlax-curve-getEndParam ename))) (fix (vlax-curve-getEndParam ename))) (setq pt (vlax-curve-GetPointAtParam ename (setq pr (1+ pr))) lst_pt (cons pt lst_pt) ) ) (setq lst_z (mapcar 'caddr lst_pt) id_seg (- (length lst_z) (length (member (apply 'min lst_z) lst_z))) ) (setq nw_pt (vlax-invoke (if (eq (getvar "CVPORT") 1) (vla-get-PaperSpace (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object))) ) 'AddPoint (nth id_seg lst_pt) ) ) (vla-put-Normal nw_pt (vlax-3d-point '(0 0 1))) ) (prin1) )
    1 point
  9. Hi, I have this that could be used as an example for creating a dimension style. I hope this inspires you to create your own dimension style. (defun c:DimPline ( / adoc space obj_dim obj_angdim height_dim pl ent obj dxf_ent last_pt pr_pt lst_pt nw_obj) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object)) space (if (= 1 (getvar "CVPORT")) (vla-get-paperspace adoc) (vla-get-modelspace adoc) ) obj_dim (vla-add (vla-get-Dimstyles adoc) "DIMPLINE") obj_angdim (vla-add (vla-get-Dimstyles adoc) "DIMANGPLINE") ) (vla-put-activedimstyle adoc obj_dim) (initget 6) (setq height_dim (getdist (getvar "VIEWCTR") (strcat "\nHeight of dimension text <" (rtos (getvar "DIMTXT")) ">: "))) (if height_dim (vla-setvariable adoc "DIMTXT" height_dim) (setq height_dim (getvar "DIMTXT"))) (mapcar '(lambda (data_list / ) (vla-setvariable adoc (car data_list) (cdr data_list))) (list (cons "DIMPOST" "") (cons "DIMAPOST" "") (cons "DIMSCALE" 1.0) (cons "DIMASZ" (getvar "DIMTXT")) (cons "DIMEXO" (* 0.625 (getvar "DIMTXT"))) (cons "DIMDLI" (* 3.75 (getvar "DIMTXT"))) (cons "DIMEXE" (* 1.25 (getvar "DIMTXT"))) (cons "DIMRND" 0.0) (cons "DIMDLE" 0.0) (cons "DIMTP" 0.0) (cons "DIMTM" 0.0) (cons "DIMFXL" (* 10.0 (getvar "DIMTXT"))) (cons "DIMFXLON" 1) (cons "DIMATFIT" 3) (cons "DIMTIX" 1) (cons "DIMCEN" (* 2.5 (getvar "DIMTXT"))) (cons "DIMTSZ" 0.0) (cons "DIMALTF" 0.0394) (cons "DIMLFAC" 1.0) (cons "DIMTVP" 0.0) (cons "DIMTFAC" 1.0) (cons "DIMGAP" (* 0.625 (getvar "DIMTXT"))) (cons "DIMALTRND" 0.0) (cons "DIMTOL" 0) (cons "DIMLIM" 0) (cons "DIMTIH" 0) (cons "DIMTOH" 0) (cons "DIMSE1" 0) (cons "DIMSE2" 0) (cons "DIMTAD" 1) (cons "DIMZIN" 0) (cons "DIMALT" 0) (cons "DIMALTD" 3) (cons "DIMTOFL" 1) (cons "DIMSAH" 0) (cons "DIMTIX" 0) (cons "DIMSOXD" 0) (cons "DIMCLRD" 0) (cons "DIMCLRE" 0) (cons "DIMCLRT" 0) (cons "DIMADEC" 2) (cons "DIMDEC" 2) (cons "DIMTDEC" 2) (cons "DIMALTU" 2) (cons "DIMALTTD" 3) (cons "DIMAUNIT" 0) (cons "DIMFRAC" 0) (cons "DIMLUNIT" 2) (cons "DIMDSEP" ".") (cons "DIMTMOVE" 0) (cons "DIMJUST" 0) (cons "DIMSD1" 0) (cons "DIMSD2" 0) (cons "DIMTOLJ" 0) (cons "DIMTZIN" 0) (cons "DIMALTZ" 0) (cons "DIMALTTZ" 0) (cons "DIMUPT" 0) (cons "DIMBLK" "_OBLIQUE") (cons "DIMBLK2" "_OBLIQUE") ) ) (vla-copyfrom obj_dim adoc) (vla-copyfrom obj_angdim adoc) (princ "\nSelect polylines: ") (while (null (setq pl (ssget '((0 . "LWPOLYLINE")))))) (repeat (setq n (sslength pl)) (setq ent (ssname pl (setq n (1- n))) obj (vlax-ename->vla-object ent) dxf_ent (entget ent) lst_pt (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) dxf_ent)) ) (if (not (zerop (logand 1 (cdr (assoc 70 dxf_ent))))) (setq last_pt (car lst_pt) lst_pt (cons (last lst_pt) lst_pt) pr_pt (last lst_pt)) (setq pr_pt nil) ) (while (cdr lst_pt) (vla-put-activedimstyle adoc obj_dim) (setq nw_obj (vla-addDimAligned space (vlax-3d-point (car lst_pt)) (vlax-3d-point (cadr lst_pt)) (vlax-3d-point (mapcar '(lambda (a b) (* (+ a b) 0.5)) (car lst_pt) (cadr lst_pt))) ) ) (vlax-put nw_obj 'TextPosition (polar (vlax-get nw_obj 'TextPosition) (+ (angle (car lst_pt) (cadr lst_pt)) (* 0.5 pi)) (* 3.25 (getvar "DIMTXT")))) (if pr_pt (progn (vla-put-activedimstyle adoc obj_angdim) (setq nw_obj (vla-AddDimAngular space (vlax-3d-point (car lst_pt)) (vlax-3d-point (polar (car lst_pt) (angle pr_pt (car lst_pt)) (distance pr_pt (car lst_pt)))) (vlax-3d-point (cadr lst_pt)) (vlax-3d-point (polar (car lst_pt) (+ (angle pr_pt (car lst_pt)) (* 0.5 (- (angle (car lst_pt) (cadr lst_pt)) (angle pr_pt (cadr lst_pt)))) ) (* 5.0 (getvar "DIMTXT")) ) ) ) pr_pt (car lst_pt) ) ) (setq pr_pt (car lst_pt)) ) (setq lst_pt (cdr lst_pt)) ) (if (cdr lst_pt) (setq nw_obj (vla-AddDimAngular space (vlax-3d-point (car lst_pt)) (vlax-3d-point (polar (car lst_pt) (angle pr_pt (car lst_pt)) (distance pr_pt (car lst_pt)))) (vlax-3d-point (cadr lst_pt)) (vlax-3d-point (polar (car lst_pt) (+ (angle pr_pt (car lst_pt)) (* 0.5 (- (angle (car lst_pt) (cadr lst_pt)) (angle pr_pt (car lst_pt)))) ) (* 5.0 (getvar "DIMTXT")) ) ) ) ) ) ) (princ) )
    1 point
×
×
  • Create New...