Jump to content

Is it possible create lisp for dimension?


titoprax

Recommended Posts

Hello everyone,

I use Qdim for dimensions but I need the totaldim.

Is it possible to create a lisp?

 

with quick dimension. tipical lisp

attachment.php?attachmentid=62365&cid=1&stc=1

 

Add new lisp

attachment.php?attachmentid=62366&cid=1&stc=1

 

Thank youicon11.gif

a.jpg

b.jpg

Link to comment
Share on other sites

titoprax yes its possible just have to do it via a lisp recording pick points and run dim twice and 2*offset for dim total. dim pt1 pt2 pt3 pt4 etc dim pt1 ptlast

Link to comment
Share on other sites

This is a start needs a vertical option to be added its just for testing needs some extra error checking etc. Maybe a distance offset for dims rather than pick a point. It needs to take into account the 4 sides and directions involved. Uisng a L R U D as 1st pass is one way around the problem.

 

; Autodim a number of points in the 4 ortho directions including a total dim.
; By Alan H Oct 2017

(defun c:adim ( / lst x y lst2 pt3 pt)

(defun AH_units ()
(SETQ ANGBASEE (GETVAR "ANGBASE"))
(SETQ ANGDIRR (GETVAR "ANGDIR"))
(SETQ LUNITSS (GETVAR "LUNITS"))
(SETQ LUPRECC (GETVAR "LUPREC"))
(SETQ AUNITSS (GETVAR "AUNITS"))
(SETQ AUPRECC (GETVAR "AUPREC"))
(SETVAR "LUNITS" 2)
(SETVAR "ANGBASE" 0.0)
(SETVAR "ANGDIR" 1)
(SETVAR "LUPREC" 0)
(SETVAR "AUNITS" 0)
(SETVAR "AUPREC" 0)
)
(defun old_AH_units ()
(SETVAR "LUNITS" lunitss)
(SETVAR "ANGBASE" angbasee)
(SETVAR "ANGDIR" angdirr)
(SETVAR "LUPREC" luprecc)
(SETVAR "AUNITS" aunitss)
(SETVAR "AUPREC" auprecc)
)

(ah_units)

(setq lst '())
(while (setq pt (getpoint "Pick dim points in sequence <Cr> to stop"))
(setq lst (cons pt lst))
)

(setq lenlst (length lst))
(setq pt3 (getpoint (nth 0 lst) "Pick offset pt"))
(setq ang (angle (nth 0 lst) pt3))

(cond
((= 0.0 ang)(setq dirrvh "VER" direc "R"))
((= (/ pi 2) ang)(setq dirrvh "HOR" direc "U"))
((= pi  ang)(setq dirrvh "VER" direc "L"))
((= (* pi 1.5) ang)(setq dirrvh "HOR" direc "D"))
)

(if (= dirrvh "HOR")
(progn
(setq lst2 (vl-sort lst
(function (lambda (e1 e2)
(< (cadr e1) (cadr e2))
))))
(setq pmax (cadr (nth (- lenlst 1) lst2)))
(setq pmin (cadr (nth 0 lst2)))
(if (= direc "U")
(setq off (- (cadr pt3) pmax))
(setq off (- (cadr pt3) pmin))
)
(setq pt4 (list  (cadr pt3)(+ off (cadr pt3))))
)
)
(if (= dirrvh "VER")
(progn
(setq lst2 (vl-sort lst
(function (lambda (e1 e2)
(< (car e1) (car e2))
))))
(setq pmax (car (nth (- lenlst 1) lst2)))
(setq pmin (car (nth 0 lst2)))
(if (= direc "R")
(setq off (- (car pt3) pmax))
(setq off (- (car pt3) pmin))
)
(setq pt4 (list (+ off (car pt3))(cadr pt3)))
)
)

(old_AH_units)
(setq x 0)
(repeat (- (length lst) 1)
(command "Dim" dirrvh (nth x lst) (nth  (+ x 1) lst) pt3 "" "exit" )
(setq x (+ x 1))
)
(command "Dim" dirrvh (nth 0 lst) (nth (- (length lst) 1) lst) pt4 "" "exit" )

(princ)
)

Edited by BIGAL
Link to comment
Share on other sites

Have a few ideas for the 4 directions to pick automatically. Worked out how do that so it knows left up etc just debugging code code now.

Edited by BIGAL
Link to comment
Share on other sites

  • 2 months later...

My apologies for bumping an older thread, but I didn't see a private message feature. I'm trying to use the program you wrote but don't understand the ending condition, " to stop." Is this a keystroke or a text input?

Link to comment
Share on other sites

To quote Homer Simpson "where is the any key".:lol:

 

For us a bit older means press Carriage return which on keyboards now is the Enter key. I use this method with pick objects also pick nothing should exit ie a blank spot on your dwg as the getpoint returns a Nil. Pressing Esc will exit but you get an error message.

Link to comment
Share on other sites

  • 4 years later...

Hi Bigal! This is another useful lisp from you!! Is there an easy way to modify your code to set a predefine offset distance when you click for the dimensions to appear? Like the first one could be 6.0 from the last pick point and the second one 12.0 from that same point? Where would I enter those informations in you code! It's probably a setq off 6.0 pi2 and setq off 12.0 pi2 but I'm not sure where to add this?

Thanks!

Link to comment
Share on other sites

Its old code now but can see that pt3 & pt4 are used for dim offset pt. I will have to have a think about how I did it and change to fixed offset. Something to do with initial pick of pt3.

Edited by BIGAL
Link to comment
Share on other sites

I've tried to add this (at both places on your code) and it worked from the first 2 dimensions compared to the overall one! After trying, 8 is better than 6 for me because the dimensions are not overlapping each other! It creates a space of 8 units in between. I also add a "minus" before the 8.0 on the "pmin" line so when I select to offset "down" or "left" the overall dimension appears far down and far left! The first click for the dimensions to appear is still manual but it doesn't really matter, it was more for the overall dimension to have enough space to not overlap the first ones! Let me know if it makes sense! Thanks again!

(setq off 8.0 pi2 (- (car pt3) pmax))

(setq off - 8.0 pi2 (- (car pt3) pmin))

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