& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
Dear Sir & Ma'am ,
I want to different types shape plate automatic dimension possible please share.
1-select object create automatic dimension
2-all holes are attributes block
3-dimension style Option 1.ordinate
2.Linear
3.ordinate with linear both
Please see the attached drawing.
Dimension required hole to hole
please see the image
post your sample drawing
Similar request has been partly solved here.
Here is code to autodim baseplate . What you need is to set system variables regarding dim text size, precision and what applicable. To create dimensions for holes add sample drawing.
(defun c:autodim ()
(defun pointlist2d (lst / ret)(while lst (setq ret (cons (list (car lst)(cadr lst)) ret) lst (cddr lst))) (reverse ret))
(defun LM:boundingbox ( obj / a b lst )
(if
(and
(vlax-method-applicable-p obj 'getboundingbox)
(not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'a 'b))))
(setq lst (mapcar 'vlax-safearray->list (list a b)))
)
(mapcar '(lambda ( a ) (mapcar '(lambda ( b ) ((eval b) lst)) a))
'(
(caar cadar)
(caadr cadar)
(caadr cadadr)
(caar cadadr)
)
)
)
)
(defun perperdicular_from_point_to_line (lin1 lin2 p / x1 y1 x2 y2 x3 y3 k m n ret)
;returns point on a line (line1 line2) as a perpendicular projection from point p
(mapcar 'set '(x1 x2 x3) (mapcar 'car (list lin1 lin2 p)))
(mapcar 'set '(y1 y2 y3) (mapcar 'cadr (list lin1 lin2 p)))
(setq
m (-(*(- y2 y1) (- x3 x1))(*(- x2 x1) (- y3 y1)))
n (+(* (- y2 y1)(- y2 y1))(*(- x2 x1)(- x2 x1)))
)
(cond
((/= n 0.0)
(setq
k (/ m n)
ret (list(- x3 (* k(- y2 y1)))(+ y3 (* k(- x2 x1))))
)
)
)
ret
)
(defun getintersections (obj1 obj2 / var)
; from RonJonP
(setq var (vlax-variant-value (vla-intersectwith obj1 obj2 2)))
(if (< 0 (vlax-safearray-get-u-bound var 1))
(vlax-safearray->list var)
) ;_ end of if
) ;_ end of defun
(defun init ( / e ent off plobj pts bbox p1 p2 p3 p4 k1 k2 k3 k4 uc_list po a b c i segs uc te to int)
(command "_.ucs" "w")
(setq e (car(entsel "\nSelect polyline to autodim >")))
(if (not (setq off (getreal "\nDimensions offset from object <20>"))) (setq off 20))
(cond
((and e)
(setq plobj (vlax-ename->vla-object e))
(setq pts (pointlist2d(vlax-get plobj 'Coordinates)))
(setq bbox (LM:boundingbox plobj))
(command "_.pline" "_non" (car bbox) "_non" (cadr bbox) "_non" (caddr bbox) "_non" (cadddr bbox) "c")
(setq p1 (car bbox) p2 (cadr bbox) p3(cadddr bbox) p4 p1)
(setq k1 (cadr bbox) k2 (caddr bbox) k3 (caddr bbox) k4 (cadddr bbox))
(setq uc_list (list (list p1 k1)(list p2 k2)(list p3 k3)(list p4 k4)))
(setq po (entlast))
(setq a (car bbox) b (mapcar '+ (car bbox) (list 0 (* -1 off))) c (distance a b))
(command "_.offset" "_non" c (entlast) "_non" a "_non" b "")
(setq e (entlast))
(setq bo (vlax-ename->vla-object e))
(setq bbox (LM:boundingbox bo))
(entdel po)
(setq i 0 segs (list))
(while (< i 3)
(setq a (nth i bbox) b (nth (+ i 1) bbox))
(if (> (car a) (car b)) (setq c a a b b c))
(setq segs (append segs (list(list a b))))
(setq i (+ i 1))
)
(setq segs (append segs (list(list (car bbox)(last bbox)))))
(entdel e)
(setq i 0)
(foreach seg segs
(setq uc (nth i uc_list))
(command "_.ucs" "w")
(command "_.ucs" "_3p" (car uc)(cadr uc) "")
(command "_.line" "_non" (trans (car seg) 0 1) "_non" (trans(cadr seg)0 1) "")
(setq te (entlast))
(foreach pt pts
(setq proj (perperdicular_from_point_to_line (trans(car seg)0 1) (trans(cadr seg)0 1) (trans pt 0 1)))
(command "_.line" "_non" (trans pt 0 1) "_non" proj "")
(setq to (vlax-ename->vla-object (entlast)))
(setq int (getintersections to plobj))
(entdel (entlast))
(command "_.dimordinate" "_non" (trans pt 0 1) "_non" proj)
(command "_.chprop" (entlast) "" "A" "Yes" "")
(if (or (= i 1) (= i 3))
(progn
(setq ent (entget(entlast)))
(setq ent (subst (cons 53 4.71238898)(assoc 53 ent) ent))
(entmod ent)
)
)
)
(setq i (+ i 1))
(entdel te)
)
)
)
)
(setvar 'cmdecho 0)
(vla-endundomark (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-startundomark (vla-get-ActiveDocument (vlax-get-acad-object)))
(init)
(command "ucs" "w")
(vla-endundomark (vla-get-ActiveDocument (vlax-get-acad-object)))
(setvar 'cmdecho 1)
(princ)
)
(princ "\n Type Autodim to dimension an polyline ")
(princ)
Delete duplicate dimensions where needed.
Miljenko Hatlak
@Gaganpatel wrote:
Dimension required hole to hole
....
[DIMPOLY isn't what you want -- it puts lengths along the edges of a Polyline, following their angles, not horizontal & vertical dimensions as in the image.]
That image [the resolution is too low, so it's hard to say for sure] doesn't look like Dimensions from "hole to hole," but rather every hole ordinate-Dimensioned separately. It looks to me like there are too many variables to automate that. Some of the ordinate Dimensions are inside the outline, and some [most] pulled outside -- how would a routine determine which should go inside and which outside? Also, not all edges of the outline are dimensioned -- how would a routine determine which should be dimensioned, and which not? If you want hole-to-hole Dimensions, post a sample of the intended result -- how far back in from an edge should it look for the next hole to include in a string of Dimensions, and which should it leave to a string from the other side, or maybe internally? Etc., etc.
Try this for a start. Further changes and code finishing possible, but only if this is
selected as a solution.
Function AUTODIM creates something like this. You only have to change dimension style.
Miljenko Hatlak
Nice Work, I think, this is his requirement..
@hak_vz wrote:
....
Function AUTODIM creates something like this. ....
And what does it create in a situation like the image in Message 3? Irregular groups of holes toward the ends, some floating in the middle between the other groups, not all in nice columns and rows, etc. [I leave it to you and/or the OP to set up the situation to try it.]
e image in Message 3? Irregular groups of holes toward the ends, some floating in the middle between the other groups, not all in nice columns and rows, etc. [I leave it to you and/or the OP to set up the situation to try it.]
In current version it creates ordinate dimension for x axis to bottom of a drawing, and to right for y axis, with origin in
lover left corner. In further changes to code I may add option to split circle dims to nearest edge. In some cases he will have to delete some dims and add hole to hole dimension by hand.
As a free solution is more then adequate. I guess on freelancer they charge at least 50 US.
Miljenko Hatlak
Can you go away and spend 3-4 hours making it do what I want but oh yeah I still want it for free how often see that on all these forums.
Dear Sir,
Thank you
Working is good
problem X-dimension ok, Y-dimension rotate.
i request possible dimension option 1-ordinate dimension
2-linear dimension
3-linear with ordinate both.
@Gaganpatel wrote:Dear Sir,
Thank you
Working is good
problem X-dimension ok, Y-dimension rotate.
i request possible dimension option 1-ordinate dimension
2-linear dimension
3-linear with ordinate both.
A) It should not rotate text in case of y ordinate (it is created as x but with rotated ucs). Try few more times. If it continues than put comments sign ";" to following lines in code and test. You have it at two locations.
;(if (or (= i 1) (= i 3))
;(progn
;(setq ent (entget(entlast)))
;(setq ent (subst (cons 53 4.71238898)(assoc 53 ent) ent))
;(entmod ent)
;)
;)
Or you can select those y ordinate dimension and change text rotation if needed.
Don't expect to receive solution to implement all you want. It is way to complex and it's hard to define logic for when to use particular dimension type. This code is here so you can automate 80 % of your work, and finish drawing by hand i.e. add or remove some dimension line.
Miljenko Hatlak
Dear Sir
I do not know auto lisp programming
interest lisp programming training
please complete the lisp file and share.
It works correct at my side. Test it after you recreate dim style. If dimension text eventually rotate correct it in properties menu - text rotation 270 to 0.
Miljenko Hatlak
@Gaganpatel I have looked through your previous posts, and as it seams that your request has been answered here by @Moshe-A I have tested that code and it works OK for linear and ordinate dimensions, it enables changing circle block. It separates linear and ordinate dimensions but there is no easy way to yoin this into a single operation .
Have you got any problem with that code?
Miljenko Hatlak
i request possible dimension option 1-ordinate dimension
2-linear dimension
3-linear with ordinate both.
Pick 1 its free
next one cost a bit
next one double the cost of a bit.
Not everything in this world is free, like others happy to discuss a fee. I request to win the lottery still has not worked.
In this routine can anyone tell me why it is coming overlapped dimensions while blocks are in one line in x-direction or y-direction.
any suggestion for deleting these duplicated dimensions.
@avinash00002002 wrote:
In this routine can anyone tell me why it is coming overlapped dimensions while blocks are in one line in x-direction or
Routine creates dimensions in left to right and bottom to top direction on all four sides of let call it a virtual rectangle i.e bottom, right top and left side and creates ordinate dimensions. For each rectangle side ucs is converted an it always create ordinate dimension in x direction. If all system variables are set correctly there is no flipping of dimension text over dimension line. If you have one or more overlapping dimension lines, erase what you don't need. Procedure is created as it is. I don't have time to change code for each individual requests. Maybe some day I'll have a web site to share my code and possibly earn some quid with it. When used correctly routine does what it is has to do and is great time saver.
If you really want me to add algorithm to remove overlaps, attach sample drawing. If you don't know how to code it write in pseudo code how you would tackle this problem. IMO solution is relatively simple but as I stated before, I want to hear for idea how you would solve it.
P:S. I have tested this code in AUTOCAD versions. Some local engineers regularly use it, with different autolisp capable CADs, and none of them didn't encounter ordinate dimension flipping in Y direction.
Miljenko Hatlak
Hi!
I have an idea to remove overlapped dimensions.
First of all, get the selection set of all dimensions, iterate one by one it's lower X value compare with other one by one dimensions by 13 of dxf value of greater than the iterate X value, if the same value of X and greater than y value then delete it. Then it run same for y value with 14 dxf code.
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name