Jump to content
titoprax

Is it possible create lisp for dimension?

Recommended Posts

titoprax

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

Share this post


Link to post
Share on other sites
guran

Why not use "DIMLINEAR" ?

Share this post


Link to post
Share on other sites
titoprax

I think it would be very useful to work with this new lisp

We would have dimension + total dimension.

Share this post


Link to post
Share on other sites
BIGAL

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

Share this post


Link to post
Share on other sites
BIGAL

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

Share this post


Link to post
Share on other sites
titoprax

Yeeaaaaaahh¡¡¡ Thank you Bigal :D

Share this post


Link to post
Share on other sites
BIGAL

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

Share this post


Link to post
Share on other sites
BIGAL

The code above has been updated and will work for 4 directions.

Share this post


Link to post
Share on other sites
aschiffer

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?

Share this post


Link to post
Share on other sites
BIGAL

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×