m4rdy 发表于 2022-7-6 12:07:18

Autodimensioning arc's pl

Hi all,
 
How can i use the command DIMARC on all arc's polyline segment(s) without picking the segment(s) and dimension location?
One more thing the dimensions have to be associative's.
Thank you for any helps.
 
M4rdy.
Autocad 2007

fixo 发表于 2022-7-6 12:14:51

 
Mardi,
This one is from my oldies
Is this what you looking for?
(Check your PM box)
 

;; Program to dimensioning all polyline segments;;fixo () 2005 all rights removed;; A2005 / Windows XP;; helper functions : written by Fatty T.O.H.;; ***group list   ***(defun group-by-num (lst num / ls ret) (if (= (rem (length lst) num ) 0)   (progn   (setq ls nil)   (repeat (/ (length lst) num)(repeat num (setq ls           (cons (car lst) ls)      lst (cdr lst)))(setq ret (append ret (list (reverse ls)))      ls nil)))   )ret );; ***coordinates***(defun get-vexs (pline_obj / verts)   (setq verts (vlax-get pline_obj 'Coordinates)    verts          (cond          ((wcmatch (vlax-get pline_obj 'Objectname )                     "AcDb2dPolyline,AcDb3dPolyline")              (group-by-num verts 3)          )          ((eq (vlax-get pline_obj 'Objectname )                     "AcDbPolyline")              (group-by-num verts 2)          )          (T nil)          )) ) ;; ***inclined angle***(defun dif-angle (ang1 ang2 / def) (set 'ang1      (if (> ang2 (+ pi ang1)) (+ (* pi 2) ang1) ang1      ) ) (set 'ang2      (if (> ang1 (+ pi ang2)) (+ (* pi 2) ang2) ang2      ) ) (setq def (- ang2 ang1)));; ***test on CW/CCW***;; (angdir=0)(defun ccw-test        (pt_list / angle_list) (setq        angle_list (mapcar (function (lambda (x y)                     (angle x y)                   )       )       pt_list       (cdr pt_list) ) ) (if (> (apply        '+        (mapcar        (function (lambda (x y) (dif-angle x y)))                angle_list                (cdr angle_list)        ) ) 0   )   t   nil ));; ***main programm***(defun C:dmp (/ ) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (setq acsp (vla-get-modelspace adoc)) (setq        pl (vlax-ename->vla-object   (car (entsel "\n >> Select pline >> \n"))   ) )(setq        coords (get-vexs pl)) (if (eq :vlax-true (vla-get-closed pl)) (setq        coords (append coords (list (car coords))))) (if (ccw-test coords)(setq dop pi)(setq dop 0)) (setq param_list (mapcar (function (lambda (x)        (fix (vlax-curve-getparamatpoint pl x))))   (mapcar (function (lambda (y)(trans y 0 1))) coords)))(mapcar (function (lambda (x y z)(cond((not (zerop (setq blg (vla-getbulge pl x))))(progn(setq hgt (* 4 (atan (abs blg)))chord (distance y z)rad (abs (/ chord 2 (sin (/ hgt 2))))mid (trans (vlax-curve-getpointatparam pl (+ (fix x) 0.5)) 0 1);;;cen (trans (mapcar (function (lambda (a b)(/ (+ a b) 2))) y z) 0 1);; fixed by Matthew :      cen (trans (polar y (if (minusp blg)(-(angle y z)(-(/ pi 2)(/ hgt 2)))              (+(angle y z)(-(/ pi 2)(/ hgt 2)))) rad) 0 1) txp (trans (polar mid (if (minusp blg)(angle cen mid)                (angle mid cen))0 1))(setq dm (vla-adddim3pointangular acsp   (vlax-3d-point cen)   (vlax-3d-point y)   (vlax-3d-point z)   (vlax-3d-point txp)))(vla-put-textoverride dm (rtos (abs (- (vlax-curve-getdistatpoint pl y)                     (vlax-curve-getdistatpoint pl z))) 2 2))))(T (progn    (setq mid (trans (vlax-curve-getpointatparam pl (+ (fix x) 0.5)) 0 1))    (setq txp (trans (polar mid (+ dop (angle y z) (/ pi 2)) 8.) 0 1))    (vla-adddimaligned acsp    (vlax-3d-point y)   (vlax-3d-point z)   (vlax-3d-point txp))    )))))param_listcoords(cdr coords)) (princ))(princ "\n\t***\tPLINE DIMENSIONING\t***\n")(princ "\nType DMP to execute\n")(prin1)
 
~'J'~

m4rdy 发表于 2022-7-6 12:16:25

Thank you FIXO for your reply.
Yes, indeed i had your DMP's. But as i posted before, is it possible to make the dimensions to be associative's?

m4rdy 发表于 2022-7-6 12:22:41

And one more thing, i found error on different UCS angle.
Command:DMP
>> Select pline >>
; error: bad argument type: numberp: nil
 
M4rdy

fixo 发表于 2022-7-6 12:28:03

 
I wrote it many moons ago for WCS only
Ok I will see what I can to rewrite for different UCS
Easier yet to set world / restore current UCS btw
 
~'J'~

fixo 发表于 2022-7-6 12:31:03

 
Hi Mardy
I figured out how to get it to work in the different UCS
just added few lines of code
Let me know how it will be work
 
~'J'~
DimPoly.LSP

m4rdy 发表于 2022-7-6 12:33:45

It works perfectly. Just curious, why do you use dimangular (vla-adddim3pointangular) then override the text for arc segments? I've tried to use dimarc, but i had no luck. What's wrong with that?
Thank you sir.
 
m4rdy

wizman 发表于 2022-7-6 12:40:06

(acdimenableupdate T)

m4rdy 发表于 2022-7-6 12:44:40

Wait a minute...FIXO i have a little problem with your dmp. If the arc segment as the last segment on closed pline, the result goes wrong.
 

fixo 发表于 2022-7-6 12:46:04

 
Ok, I will try
 
~'J'~
页: [1] 2
查看完整版本: Autodimensioning arc's pl