Jump to content

Auto dimension objects within polyline to polyline edge on x axis


claire2017

Recommended Posts

Hi helpful people :)

 

Does anyone know if there is an easy way to auto-dimension as per attached image, by selecting the polyline & circles in one hit? I have thousands of these to do and the amount of time it takes to put a linear dimension on each hole is crazy!

I've tried qdim but it doesnt give me what i'm after.

 

Thanks in advance,

Claire :)

 

 

Dimensions.JPG

Link to comment
Share on other sites

I just have one question have you made the posted image to be a 3d view ? so dims are vertical ?

 

To dim all the circles horizontally would be pretty easy just make a false line that extends past the pline shape draw horizontal and just dim the left intersecting point with the centre the right and center, please confirm about 3d. Oh it is easy to find the circles (ssget "wp" ....

Link to comment
Share on other sites

Hey bigal, 

No it’s not 3D, that’s the shape in 2d. 

I was hoping to find something similar to qdim where it automatically dims them all at once, I can do them as you said but I have thousands of them & it’s super time consuming! 

😊

Link to comment
Share on other sites

OK, No answer to the above so I've assumed they all look like the above.

 

Try the attached (Updated). It is cobbled together from different routines, works (minimally tested) but you need to have the correct dimstyle set as current. I have assume the placement point for the dims to be 3 units up (y axis) from the centre of the circle. It looks correct but may need adjusting. Selection is (ssget), don't select too many groups at a time as it will slow down considerably 

 

 

 

 

dimcir.lsp

Edited by dlanorh
Updated attached file
Link to comment
Share on other sites

Dlanorh, this is perfect, you are amazing!

 

Yes they all look and are dimensioned exactly the same as that first pic just slight variations in sizing.

 

This has saved me so many hours & a lot of frustration.

 

Thankyou,

Claire :)

Link to comment
Share on other sites

I have again updated the file attached above. I have indicated where you can change the dimension positioning, and speeded the code up a bit by removing dimensioned circles from the list.

Link to comment
Share on other sites

Leaving my attempt just for the record (works with circles only) -


(defun C:test ( / PolygonsLayer dimoff fuzz *error* SS acDoc spc )
  
  (setq ; adjust these to suit:
    PolygonsLayer "VLD_TEXT"
    dimoff (* 2 (getvar 'textsize))
    fuzz nil
  ); setq
  
  (defun *error* ( m )
    (and acDoc (vla-EndUndoMark acDoc))
    (and m (princ m)) (princ)
  ); defun *error*
  
  (setq fuzz (cond (fuzz)((progn (initget 4) (getint "\nSpecify fuzz factor <1e-3> :"))) (1e-3)))
  (and 
    (setq SS (ssget "_:L" (list '(0 . "LWPOLYLINE") (cons 8 PolygonsLayer) '(-4 . "&=") '(70 . 1))))
    (setq spc (vla-get-Block (vla-get-ActiveLayout (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))))))
    (progn (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc) t)
    (
      (lambda ( SS )
        (repeat (setq i (sslength SS))
          (DimCirclePositionsInsideLwPoly (ssname SS (setq i (1- i))) spc dimoff fuzz)
        )
      )
      SS
    )
  ); and
  (*error* nil)
  (princ)
); defun C:test


; Dimensions circlese's positions, located within the specified polygon
(defun DimCirclePositionsInsideLwPoly ( polygon spc off fuzz / mid o SS i enx p cL spc )
  (cond 
    ( (not (eq 'ENAME (type polygon))) )
    ( (not ((lambda (L enx) (vl-every '(lambda (x) (member x enx)) L)) '((0 . "LWPOLYLINE")(70 . 1)) (entget polygon))) )
    (
      (progn
        (setq mid (lambda (p1 p2) (mapcar (function (lambda (a b) (* 0.5 (+ a b)))) p1 p2)))
        (setq o (vlax-ename->vla-object polygon))
        (if (setq SS (ssget "_WP" (apply 'append (mapcar '(lambda (x) (if (= 10 (car x)) (list (cdr x)))) (entget polygon)))  '((0 . "CIRCLE"))))
          (repeat (setq i (sslength SS))
            (setq p (cdr (assoc 10 (setq enx (entget (ssname SS (setq i (1- i))))))))
            (cond 
              ( (and cL (vl-some '(lambda (x) (equal p (cdr x) fuzz)) cL)) )
              ( (setq cL (cons (cons (cdr (assoc 40 enx)) p) cL)) )
            )
          )
        )
        (not cL)
      )
    )
    ( ; (setq spc (vla-get-Block (vla-get-ActiveLayout (vla-get-ActiveDocument (vlax-get-acad-object)))))
      (mapcar 
        '(lambda (x / r p p1 p2 p3 p4 xlx xly pL )
          (setq r (car x) p (cdr x))
          (mapcar 'set '(p1 p2 p3 p4) (mapcar '(lambda (x) (polar p x r)) (list (* PI 0.0)(* PI 1.0)(* PI 0.5)(* PI 1.5))))
          (and
            (setq xlx (vlax-invoke spc 'AddXline p1 p2))
            (setq pL (vlax-invoke xlx 'IntersectWith o acExtendNone))
            (setq pL (vl-sort (cons p ('((f L)(f L)) '(( L ) (if L (cons (mapcar ''( (x) (nth x L)) '(0 1 2)) (f (cdddr L))))) pL)) '(lambda (a b) (< (car a) (car b)))))
            (setq pL (LM:UniqueFuzz pL fuzz))
            (mapcar '(lambda (a b) (vlax-invoke spc 'AddDimAligned a b (polar (mid a b) (+ (angle a b) (* 0.5 PI)) off))) pL (cdr pL))
          )
          (and
            (setq xly (vlax-invoke spc 'AddXline p3 p4))
            (setq pL (vlax-invoke xly 'IntersectWith o acExtendNone))
            (setq pL (vl-sort (cons p ('((f L)(f L)) '(( L ) (if L (cons (mapcar ''( (x) (nth x L)) '(0 1 2)) (f (cdddr L))))) pL)) '(lambda (a b) (< (cadr a) (cadr b)))))
            (setq pL (LM:UniqueFuzz pL fuzz))
            (mapcar '(lambda (a b) (vlax-invoke spc 'AddDimAligned a b (polar (mid a b) (+ (angle a b) (* 0.5 PI)) off))) pL (cdr pL))
          )
          (and xlx (vla-Delete xlx)) 
          (and xly (vla-Delete xly))
        )
        cL
      )
    )
  )
)

;; Unique with Fuzz  -  Lee Mac
;; Returns a list with all elements considered duplicate to
;; a given tolerance removed.

(defun LM:UniqueFuzz ( l f / x r )
  (while l
    (setq x (car l)
      l (vl-remove-if (function (lambda ( y ) (equal x y f))) (cdr l))
      r (cons x r)
    )
  )
  (reverse r)
)

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...