Author Topic: PERPENDICULAR DIMENSION  (Read 1349 times)

0 Members and 1 Guest are viewing this topic.

REGHUYES

  • Newt
  • Posts: 21
PERPENDICULAR DIMENSION
« on: January 04, 2021, 03:08:06 AM »
How to modify this code for cross dimensions ( sample image attached ,dimension marked in red ) ?
 
[open]     (defun c:test (/ coords poly2)
    (setq cords   (Poly-Pts (vlax-ename->vla-object
               (car (entsel "\nFirst poly:"))
           )
      )
     poly2   (vlax-ename->vla-object (car (entsel "\nSecond poly:")))
    )
    (foreach x cords
   (vl-cmdf "dimaligned"
       x
       (vlax-curve-getclosestpointto poly2 x)
       x
   )

    )
   
)

;;; Poly-Pts (gile)
;;; Returns the vertices list of any type of polyline (WCS coordinates)
;;;
;;; Argument
;;; pl : a polyline (ename or vla-object)

(defun Poly-Pts   (pl / pa pt lst)
    (vl-load-com)
    (setq pa (if (vlax-curve-IsClosed pl)
       (vlax-curve-getEndParam pl)
       (+ (vlax-curve-getEndParam pl) 1)
        )
    )
    (while (setq pt (vlax-curve-getPointAtParam pl (setq pa (- pa 1))))
   (setq lst (cons pt lst))
    )
)   
  [/close]

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: PERPENDICULAR DIMENSION
« Reply #1 on: January 04, 2021, 11:25:54 PM »
You may need to take a different approach a quick idea draw a line to left and another to right horizontal compare intersect with distance shortest is correct to use, same with vertical dims draw vertical line from each point shortest again use with dim ver.

Using a xline "hor" option gives the 2 external points that you want.

(setq intpt2 (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity))
(418.0 148.0 0.0 284.0 148.0 0.0)

Do you understand lisp so can do this ?
A man who never made a mistake never made anything

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: PERPENDICULAR DIMENSION
« Reply #2 on: January 05, 2021, 03:38:48 AM »
For intersection see also:
Code: [Select]
 
; original _polyinters Lee Mac
; Use: (_polyinters_Ext en p1 p2 nil)
;
 (defun _polyinters_Ext ( en p1 p2 TrueFl / vl )
     (setq en (entget en)
           vl (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) en))
     )
     (vl-remove-if 'null
         (mapcar '(lambda ( p3 p4 ) (inters p1 p2 p3 p4 TrueFl)) ;<<<<<< added TrueFl
             vl
             (if (= 1 (logand 1 (cdr (assoc 70 en))))
                 (append (cdr vl) (list (car vl)))
                 (cdr vl)
             )
         )
     )
 )