Author Topic: Help with dimension lisp  (Read 1863 times)

0 Members and 1 Guest are viewing this topic.

PM

  • Guest
Help with dimension lisp
« on: August 05, 2021, 11:33:38 AM »
Hi i have  lines / polylines   on layers OG and RG. I want to draw dimesion in specific dimension style with name _DIM . This dimensions must be from the midle of each line or the midle of polyline vertex from layer OG and perpedicular to RG layer line/poilyline.

The code must search for this layers and wihtout any selection from the user insert the dimension. The dimension style is allready loaded in the template of the drawing. Look the attach  test.dwg
The dimension style is annotated.


Thanks

JohnK

  • Administrator
  • Seagull
  • Posts: 10638
Re: Help with dimension lisp
« Reply #1 on: August 05, 2021, 01:14:45 PM »
How far have you gotten (or do you just want someone else to write it for you)?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

PM

  • Guest
Re: Help with dimension lisp
« Reply #2 on: August 05, 2021, 04:11:59 PM »
I have this code but is not what i am searching for

Code - Auto/Visual Lisp: [Select]
  1. (defun c:vertdim (/ coords poly2)
  2.   (setvar "osmode" 0)
  3.   (setq cords (Poly-Pts (vlax-ename->vla-object(car (entsel "\nFirst poly:"))))
  4.         poly2 (vlax-ename->vla-object (car (entsel "\nSecond poly:")))
  5.         )
  6.   (foreach x cords
  7.     (vl-cmdf "dimaligned" x (vlax-curve-getclosestpointto poly2 x) x)
  8.     )
  9.   (setvar "osmode" 9)  
  10.   )
  11.  
  12. ;;; Poly-Pts (gile)
  13. ;;; Returns the vertices list of any type of polyline (WCS coordinates)
  14. ;;;
  15. ;;; Argument
  16. ;;; pl : a polyline (ename or vla-object)
  17.  
  18. (defun Poly-Pts (pl / pa pt lst)
  19.              (vlax-curve-getEndParam pl)
  20.              (+ (vlax-curve-getEndParam pl) 1)
  21.            )
  22.   )
  23.   (while (setq pt (vlax-curve-getPointAtParam pl (setq pa (- pa 1))))
  24.     (setq lst (cons pt lst))
  25.   )
  26. )
  27.  

Thanks

PM

  • Guest
Re: Help with dimension lisp
« Reply #3 on: August 06, 2021, 01:04:54 AM »
Any ideas?

Thanks

BIGAL

  • Swamp Rat
  • Posts: 1411
  • 40 + years of using Autocad
Re: Help with dimension lisp
« Reply #4 on: August 06, 2021, 03:09:24 AM »
Maybe google forums/autodesk Kent Cooper something like label plines.
A man who never made a mistake never made anything

PM

  • Guest
Re: Help with dimension lisp
« Reply #5 on: August 06, 2021, 12:40:25 PM »
Hi i want to insert perpedicular dimension fron OG layer line/polyline to RG layer line/polyline

PM

  • Guest
Re: Help with dimension lisp
« Reply #6 on: August 09, 2021, 09:21:29 AM »
Any ideas?

Thanks

mhupp

  • Bull Frog
  • Posts: 250
Re: Help with dimension lisp
« Reply #7 on: August 09, 2021, 03:41:40 PM »
Not 100% doesn't put  a dim on the last leg of the poly. just added on to the poly-cords to calculate the midpoints. and pass that to your vertdim lisp.

Code: [Select]
(defun c:vertdim (/ coords poly2)
  (setvar "osmode" 0)
  (setq cords (Poly-MidPts (vlax-ename->vla-object (car (entsel "\nFirst poly:"))))
        poly2 (vlax-ename->vla-object (car (entsel "\nSecond poly:")))
  )
  (foreach x cords
    (vl-cmdf "dimaligned" "non" x (vlax-curve-getclosestpointto poly2 x) "non" x)
  )
  (princ)
)

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

(defun Poly-MidPts (pl / a b i MPT MPTlst 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))
  )
  (setq i 0)
  (repeat (setq end (- (Length lst) 1))
    (setq a i)
    (setq b (1+ i))
    (setq MPT (polar (nth a lst) (angle (nth a lst) (nth b lst)) (/ (distance (nth a lst) (nth b lst)) 2)))
    (setq MPTlst (cons MPT MPTlst))
    (setq i (1+ i))
  )
  (setq MPT (polar (nth 0 lst) (angle (nth 0 lst) (nth end lst)) (/ (distance (nth 0 lst) (nth end lst)) 2)))
  (setq MPTlst (cons MPT MPTlst))
  (setq lst MPTlst)
)

also only tested it on the red poly as first pick the green.
if you do green then red it will put dimensions on those chamfer's.
« Last Edit: August 09, 2021, 05:34:31 PM by mhupp »

PM

  • Guest
Re: Help with dimension lisp
« Reply #8 on: August 09, 2021, 04:14:45 PM »
hI  mhupp. Thanks for the replay.I try your but

1)It work only for polylines
2) is not working correct
3) and create a zero length dimensions

Quote
Hi i have  lines / polylines   on layers OG and RG. I want to draw dimesion in specific dimension style with name _DIM . This dimensions must be from the midle of each line or the midle of polyline vertex from layer OG and perpedicular to RG layer line/poilyline.

The code must search for this layers and wihtout any selection from the user insert the dimension. The dimension style is allready loaded in the template of the drawing. Look the attach  test.dwg
The dimension style is annotated.


mhupp

  • Bull Frog
  • Posts: 250
Re: Help with dimension lisp
« Reply #9 on: August 09, 2021, 05:33:43 PM »
I don't have the know how to make it for lines. the 0 lengths should be fixed now.

PM

  • Guest
Re: Help with dimension lisp
« Reply #10 on: August 10, 2021, 06:04:16 PM »
Thanks mhupp

mhupp

  • Bull Frog
  • Posts: 250