Lisp for Dimensions

Lisp for Dimensions

sharmaudit1189
Participant Participant
926 Views
2 Replies
Message 1 of 3

Lisp for Dimensions

sharmaudit1189
Participant
Participant

Hellos friends I have a small issue here I have over 200 or more of points and I need to measure dimensions points to perpendicular to line (Please refer below snaps), but in acad there is only one dimension create in one time. Can anyone help me for lisp. That would be great. Thanks in advance.  

ACAD.jpg

0 Likes
927 Views
2 Replies
Replies (2)
Message 2 of 3

cadffm
Consultant
Consultant

I do not take any responsibility for it.

 

 

Sebastian

0 Likes
Message 3 of 3

joselggalan
Advocate
Advocate

I hope this helps you.

Image_5.gif

 

 

;;=========================== C:tstfunc005 ====================================
;; Jose L. García G. -  18/08/17                                               
;;=============================================================================
(defun C:tstfunc005 ( / oCurve ssPoints
	               ;|functions|; jlgg-SSToList jlgg-MakeRotatedDimension 
		    )
	;;-------------------------- jlgg-SSToList -----------------------
	;; Selection set --> list of entities                             
	;;----------------------------------------------------------------
	(defun jlgg-SSToList (ss / ssl n)
	 (if (and ss (= (type ss) 'PICKSET))
	  (repeat (setq n (sslength ss))
	   (setq ssl (cons (ssname ss (setq n (1- n))) ssl))))
	);c.defun
 
	;;------------------------ jlgg-MakeRotatedDimension ----------------------------
	;;Crea una cota Girada                                                          
	;;Jose L. García G. - Hispacad.com                                              
   	;;------------------------------------------------------------------------------
	(defun jlgg-MakeRotatedDimension (Pt1 Pt2 PtTxT Txt / LstMk EntCota ModEnt)
	 (cond ((not Txt) (setq Txt ""))
	       ((= (vl-string-trim " " Txt) "") (setq Txt "")))
	 (setq LstMk
	  (list
	   '(0 . "DIMENSION") '(100 . "AcDbEntity")'(100 . "AcDbDimension")
	    ;;(cons 8 *LAY*)
	    (cons 11 PtTxT)(cons 10 PtTxT) 
	   '(12 0.0 0.0 0.0) '(70 . 32)
	    (cons 1 Txt)
	   '(71 . 5) '(72 . 1)
	   '(41 . 1.0) '(42 . 0.0)'(52 . 0.0) '(53 . 0.0) '(54 . 0.0) '(51 . 0.0) 
	   (cons 3 (getvar "DIMSTYLE"))
	   '(100 . "AcDbAlignedDimension")
	   (cons 13 Pt1)
	   (cons 14 Pt2)
	   '(15 0.0 0.0 0.0) '(16 0.0 0.0 0.0)
	   '(40 . 0.0)
	   (cons 50 (angle pt1 pt2))
	   '(100 . "AcDbRotatedDimension")
	  );c.list
	 );c.setq
	 (setq EntCota (entmakex LstMk))
	);c.defun
 
 ;;------------------------ MAIN ----------------------------------------
 (cond
  ((and (not (prompt "\nSelect curve base: "))
	(not (setq oCurve (ssget "_:S:E:N" '((0 . "*LINE,ARC,ELLIPSE,CIRCLE"))))))
   (prompt "\nNo valid base curve selected: (poliline, line, arc, circle, spline, ellipse,..)")
  )
  ((and (not (prompt "\nSelect points: "))
	(not (setq ssPoints (ssget '((0 . "POINT"))))))
   (prompt "\nNo points selected..")
  )
  (T
   (setq oCurve (ssname oCurve 0)) oCurve ssPoints
   (mapcar
    (function
     (lambda (oPt / Ang pnt p1)
      (setq pnt (cdr (assoc 10 (entget oPt))))
      (setq p1 (vlax-curve-getClosestPointTo oCurve pnt));point on curve
      (setq Ang (angle p1 pnt))
      (jlgg-MakeRotatedDimension pnt p1 (polar pnt Ang 0.01) "")
     )
    )
    (jlgg-SSToList ssPoints)
   )
  )
 );c.cond
 (princ)
)

(princ)

 

 

regards.

0 Likes