Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help making a Dimension LISP

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
TwelfthCoin
831 Views, 3 Replies

Need help making a Dimension LISP

I'm still new to writing LISPS to make things a easier in my day to day. right now I'm constantly having to add in text behind the behind the dimension after creating each dimension. Is it possible to get it to come in on a different layer instead of having to switch the layer each time, i tried my hand at getting it to work but I hit a wall. Could someone give me a hand at fixing the below?

 

(Defun c:PTP ()
(command "_.dimlinear")
(setq newdim (ssget))
(setq newdimvalue "<>\ PT-PT")
(command "dimedit" "n" newdimvalue newdim "")
(command "_.chprop" newdim "" "LA" "LAYER TITLE")
(princ)
)

3 REPLIES 3
Message 2 of 4
Kent1Cooper
in reply to: TwelfthCoin


@TwelfthCoin wrote:

... I'm constantly having to add in text behind the ... dimension after creating each dimension. Is it possible to get it to come in on a different layer instead of having to switch the layer each time...?

 

(Defun c:PTP ()
(command "_.dimlinear")
(setq newdim (ssget))
(setq newdimvalue "<>\ PT-PT")
(command "dimedit" "n" newdimvalue newdim "")
(command "_.chprop" newdim "" "LA" "LAYER TITLE")
(princ)
)


Your (command) function leaves you in the Dimlinear command without accounting for the User's inputs.  If you use (command-s) instead, it will wait for you to complete the command.

 

I suggest using (entlast) to get the Dimension just drawn, so you don't need to select it with (ssget).

 

If by "behind" you mean "underneath" on a new line, the code for a line feed in Dimension text content is \\P.

 

Your CHPROP command needs another Enter at the end, to tell it you're done changing properties [you could go on an specify more of them to change].

 

Something like [untested] :

 

(Defun c:PTP (/ newdim newdimvalue)
  (command-s "_.dimlinear")
  (setq newdim (entlast))
  (setq newdimvalue "<>\\PPT-PT")
  (command "dimedit" "n" newdimvalue newdim "")
  (command "_.chprop" newdim "" "LA" "LAYER TITLE" "")
  (princ)
)

Kent Cooper, AIA
Message 3 of 4
TwelfthCoin
in reply to: Kent1Cooper

It works perfect, thanks for getting me a fix so quick. As you can tell im still new to it and just getting by looking up what I can. 

 

Thanks again

Message 4 of 4
Kent1Cooper
in reply to: Kent1Cooper

Since that apparently did work....  I'll suggest a slight further consolidation.  Any variable that is used only once may as well be written in where it's used, directly, rather than by way of a variable.  And you can put more than one command into a single (command) function.  [It's faster not to be getting out of a (command) function and then opening another, though for this little amount of work you would never notice the time difference.]

 

(Defun c:PTP (/ newdim)
  (command-s "_.dimlinear")
  (setq newdim (entlast))
  (command

    "dimedit" "n" "<>\\PPT-PT" newdim ""
    "_.chprop" newdim "" "LA" "LAYER TITLE" ""

  )
  (princ)
)

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report