Jump to content

Changing variable levels, lisp???


Nellie

Recommended Posts

Hi Guys 7 Girls,

 

This is my first thread so please br gentle.

 

I was hoping somone could help me find a lisp online that can change variable (number) levels by a plus or minus value.

 

It will take a good days work doing them one at a time so your help would be very much appriciated.

 

Thanks in advance and i hope i've made myself clear.

 

Regards

 

Nellie

Link to comment
Share on other sites

Hi Nellie,

 

Not sure if this is suitable for your needs, let me know if it is what you are after.

 

 
;increases number by 1
(defun c:addone()
(setq ent (car (entsel "\nSelect Text object...")))
(while (/= nil ent)
(setq ent (entget ent))
(setq count (atoi (cdr (assoc 1 ent))))
(setq count (+ 1 count))
(chg_txt)
(setq ent (car (entsel "\nSelect Text object...")))
) ; end while
(princ)
)
(defun  chg_txt()
(setq ent
(subst (cons 1 (itoa count))
(assoc 1  ent)
       ent))
(entmod ent)
)

 

or for minus...

 

 
;decreases number by 1
(defun c:minusone()
(setq ent (car (entsel "\nSelect Text object...")))
(while (/= nil ent)
(setq ent (entget ent))
(setq count (atoi (cdr (assoc 1 ent))))
(setq count (- count 1))
(chg_txt)
(setq ent (car (entsel "\nSelect Text object...")))
) ; end while
(princ)
)
(defun  chg_txt()
(setq ent
(subst (cons 1 (itoa count))
(assoc 1  ent)
       ent))
(entmod ent)
)

 

Hope this helps :)

Link to comment
Share on other sites

Hi Lee Mac,

 

Thanks for quick reply, I've not used a lisp before and have been told that i need to run a " macro DVB format" as well as a lisp.

 

Is this correct or could you please confirm the correct process?

Thanks again

Nellie

Link to comment
Share on other sites

Hi Lee Mac,

 

Thanks for quick reply, I've not used a lisp before and have been told that i need to run a " macro DVB format" as well as a lisp.

 

Is this correct or could you please confirm the correct process?

 

Thanks again

 

Nellie

Look here...

Link to comment
Share on other sites

Thanks Ipseifert/Carl B,

 

would you mind just confirming that once loaded i run the lisp by trping the lisp name in the command line?

 

Also do i need to create a macro DVB?

 

Cheers

 

Nellie

Link to comment
Share on other sites

I am using AutoCAD 2004, and the LISP should work on AutoCAD 2006 as well.

 

I dont think you need a macro dvb format, I would usually copy the LISP text (in the code box) into a notepad entry and save the file as a ".lsp" file.

 

Then, in ACAD go to "Tools" "Load Application" and browse for the LSP file and load it.

 

To run the LISP, type the syntax shown after the prefix "(defun c:XX " (where "XX" is the syntax... i.e. "addone" or "minusone") or alternatively, assign a toolbar button to run this syntax.

 

Hope this helps :)

Link to comment
Share on other sites

Here is a lisp that allows you add or subtract a value to multiple text we use in road designs where sometimes just need to raise a road a constant amount saves re plotting the whole lot again

 

;Adds a fixed amount to a number
(PRINC "TO USE JUST TYPE A2L")
(DEFUN c:A2L ()

(setvar "cmdecho" 1)
(setq v2 (getreal "\nEnter ht adjustment "))
(setq test 1)
(while (= test 1)
     (setq en1 (car (entsel "\nSelect text number:" )))
     (if (/= en1 nil)
       (progn
       (setq el1 (entget en1))
       (setq v1 (atof (cdr (assoc 1 el1))))
       (setq a (+ v1 v2))
       (setq b (rtos a 2 3))
       (setq el (subst (cons 1 b) (assoc 1 el1) el1))
       (entmod el)
;        (entupd en1)
       );progn
      (princ "\nplease pick again"); else
    );if
); while true
); END DEFUN
(setq el nil)
(setq en nil)
(setq a nil)
(setq v1 nil)
(setvar "cmdecho" 1)
(princ)

Its one at a time pick but still way quicker.

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