Jump to content

Autodimensioning arc's pline segment(s)


m4rdy

Recommended Posts

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

Link to comment
Share on other sites

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

 

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_list
coords
(cdr coords))

 (princ)
)

(princ "\n\t***\tPLINE DIMENSIONING\t***\n")
(princ "\nType DMP to execute\n")
(prin1)

 

~'J'~

Link to comment
Share on other sites

Thank you FIXO for your reply.

Is this what you looking for?

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

Link to comment
Share on other sites

And one more thing, i found error on different UCS angle.

Command: DMP

>> Select pline >>

; error: bad argument type: numberp: nil

 

M4rdy

 

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'~

Link to comment
Share on other sites

And one more thing, i found error on different UCS angle.

Command: DMP

>> Select pline >>

; error: bad argument type: numberp: nil

 

M4rdy

 

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

(acdimenableupdate T) Hi Wizman,

How are you doing?

Did you finish your 'future addition'?

I see (acdimenableupdate T) works for STRETCH command, but it doesn't for GRIP edit.

 

m4rdy

DMP-problem.JPG

Link to comment
Share on other sites

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.

 

Hi Wizman,

How are you doing?

Did you finish your 'future addition'?

I see (acdimenableupdate T) works for STRETCH command, but it doesn't for GRIP edit.

 

m4rdy

 

Ok, I will try

 

~'J'~

Link to comment
Share on other sites

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.

 

Hi Wizman,

How are you doing?

Did you finish your 'future addition'?

I see (acdimenableupdate T) works for STRETCH command, but it doesn't for GRIP edit.

 

m4rdy

 

I have added both dimensioning for bulged segments -

angle dimension and arc dimension

Try again

 

~'J'~

DimPoly.LSP

Link to comment
Share on other sites

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.

 

Hi Wizman,

How are you doing?

Did you finish your 'future addition'?

I see (acdimenableupdate T) works for STRETCH command, but it doesn't for GRIP edit.

 

m4rdy

 

 

Doing fine here Mardy, Here's my latest Mdim.Lsp.

MDim_02DEC09.lsp

Link to comment
Share on other sites

Hi FIXO,

 

Till now your routine works well. Thank you for your kindness, sir.

 

Wizman, as always ..many thanks (..again..and ..again).:)

 

m4rdy

Link to comment
Share on other sites

Hi FIXO,

 

Till now your routine works well. Thank you for your kindness, sir.

 

Wizman, as always ..many thanks (..again..and ..again).:)

 

m4rdy

 

You're welcome

Cheers :)

 

~'J'~

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...