Jump to content

Automatic Dimensioning


Can

Recommended Posts

Hello everyone;

 

 

I need a lisp code which puts dimension automatically between the center of each circle chosen and endpoints of chosen lines as shown in the attached drawing.

 

 

Thanks.

dim_test.dwg

Link to comment
Share on other sites

I need a lisp code

 

We all need something !

 

Something like pick 1st circle, pick last and it counts the circles in between if greater than 3 then label as num x dist. May need an extra step as pick orientation at very start but only needed once. Use ssget "CP" & circle on a layer. Dont have anything but I think its achievable. Just need to check about CP when using a different UCS.

Link to comment
Share on other sites

Thank you for your answer Bigal,

 

 

Frankly, I am not good at LISP, I am just a beginner.

I would like to ask for the code it self if it is possible and convinient. Bucause I need to do it urgently.

 

 

thanks in advance.

Link to comment
Share on other sites

Try this.

 

Ps dimmed the whole lot in one go !

 

; dim bolts
; by Alan H june 2017



(defun dim1  (offx /  )
(repeat x 
(setq pt2 (nth (setq x (- x 1)) lst))
(command "Dimlinear" pt1 pt2  offx  )
(setq pt1 pt2)
)
)

(defun dim2  (offx / ptlast objpt)
(setq ptlast (nth 0 lst))
(setq howmany (rtos x 2 0))
(setq len ( / (- (car pt1) (car  ptlast)) x))
(setq ans (strcat (rtos x 2 0) "x" (rtos len 2 2)))
(command "Dimlinear" pt1 ptlast "T" ans offx )
)

(defun C:dimbolt ( /   ss lst circen pt2 pt1 xoff)
(setq oldsnap (getvar "osmode"))
(setq oldang (getvar "units"))
(setvar "Aunits" 3)

(if (/= alertused nil)
(princ)
(progn
(alert "You need to pick a line near bolt holes for orientation\n\nthis message will not appear again")
(setq alertused "Y"))
)
(princ "\nPick a line etc for dim alignment ")
(setq obj (entsel  "\nPick a line etc for dim alignment "))
(command "UCS" "OB" obj)
(setq ent (entget (car obj)))
(setq stp (cdr (assoc 10 ent)))
(setq stp (trans stp (car obj) 1))
(setq endp (cdr (assoc 11 ent)))
(setq endp (trans endp (car obj) 1))
(setq ang (+ (/ pi 2.0) (angle stp endp)))
(setq xoff (polar stp ang 400))
;(setq xoff (getpoint stp "Pick point for dim"))
(setq ss (ssget (list (cons 0 "Circle"))))
(setq lst '())
(repeat (setq x (sslength ss))
(setq cen (vla-get-center  (vlax-ename->vla-object (ssname ss (setq x (- x 1))))))
(setq circen  (vlax-safearray->list (vlax-variant-value cen)) )
(setq circen (trans circen 0 1))
(setq lst (cons circen lst))
)

; Now sort on x
(setq lst (vl-sort lst
(function (lambda (e1 e2)
(< (car e1) (car e2)))))
)

;(setq xoff (getpoint "Pick dim offset point"))

(setq x (length lst))
(setq pt1 (nth (setq x (- x 1)) lst))

(setvar "osmode" 0)

(setq ans (getstring "Do All Y or min 3 <Cr>"))
(if (= ans "") 
(dim2 xoff)
(dim1 xoff)
)
(command "ucs" "world")
(setvar "osmode" oldsnap)
(setvar "Aunits" oldang)
(princ)
)

(C:dimbolt)

Edited by BIGAL
Link to comment
Share on other sites

  • 2 weeks later...

Thank you very much for your effort.

 

 

We had one week holiday, so last week i could not check your code. I will try soon and let you know.

 

 

Thanks again.

Link to comment
Share on other sites

  • 4 weeks later...

Please down load code above the dim spacing I fixed it now shows 5x40. The offset is 400 hard coded the problem is it uses a method of start and end of a line so it may draw the dim on wrong side with a bit of use you should get used to picking the parallel line top or bottom and know which side the dim will appear. To pick side thats version 3 more code needed. There is a check vector direction method but you still have to pick a side.

Link to comment
Share on other sites

Thank you very much for your efforts.

 

 

However, there is problem related to dimensioning as i tried to explain in the attached drawing.

 

 

Actually i have a basic lisp code which is also not able to put "6x40" detail.

 

 

Attached you can find the code, also below video shows how it works.

 

 

I thing you can use "UCS_OB" in this way.

 

 

 

 

thanks again

 

 

Edited by Can
Link to comment
Share on other sites

  • 1 month later...

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