OFFSET AND CHANGE COLOR RETAINING PARAMETER

OFFSET AND CHANGE COLOR RETAINING PARAMETER

Anonymous
Not applicable
1,009 Views
5 Replies
Message 1 of 6

OFFSET AND CHANGE COLOR RETAINING PARAMETER

Anonymous
Not applicable

Good day, 

I would like to ask if any one of you know how to offset and change the color but retaining old parameter if command is repeated? I already have the ColorOffset lisp, but the problem with it is that it does not retain the previous distance given. Does any of you know how the code for it to retain previous distance? or if there is an existing lisp like this? Thanks in advance. If I made a mistake, please do enlighten me.

0 Likes
Accepted solutions (1)
1,010 Views
5 Replies
Replies (5)
Message 2 of 6

pbejse
Mentor
Mentor

@Anonymous wrote:

, but the problem with it is that it does not retain the previous distance given. Does any of you know how the code for it to retain previous distance? 


 

HYG

Where d is the variable name for distance and should not be declared as local

 

(setq d (cond ((getdist
        (strcat "\nEnter Distance <" (rtos (setq d
              (cond ( d ) ( 100.00 ))) 2 ) ">: "
        )
      )
    )
    ( d )
  )
)

 

Let us know if you need more help

 

And Welcome to the forum @Anonymous  🙂

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thanks pbejse, but can i just insert in this program? this is the ColorOffset Lisp that i am using. I'm kinda new to codes, i tried inserting the code you gave but it confuses the program.

 

(defun c:ccd ( / cmd off ent entna pk entn )
(setq cmd (getvar "CMDECHO"))
(setq OFOK 1)
(setq ENOK 1)
(setq off (getdist "\noffset distance:"))
(if (= off nil)
(setq OFOK 0))
(if (= OFOK 1)
(setq ent (entsel "\nselect object to offset:")))
(if (= ent nil)
(setq ENOK 0))
(if (and (= OFOK 1)(= ENOK 1))
(progn
(setq entna (nth 0 ent))
(redraw entna 3)
(setq ent (nth 1 ent))
(setq pk (getpoint "\nside to offset?"))
(setvar "CMDECHO" 0)
(command "_.OFFSET" off ent pk)
(command)
(command)
(setq entn (entlast))
(command "_.CHANGE" entn "" "_P"
"_C" (getvar "CECOLOR")
"_LA" (getvar "CLAYER")
"_LT" (getvar "CELTYPE")
""
)
(setvar "CMDECHO" cmd)
(redraw entna 4)
)
)
(princ)
)

0 Likes
Message 4 of 6

pbejse
Mentor
Mentor
Accepted solution

@Anonymous wrote:

Thanks pbejse, but can i just insert in this program? this is the ColorOffset Lisp that i am using. I'm kinda new to codes, i tried inserting the code you gave but it confuses the program.

 


(defun c:ccd (/ cmd  ent entna pk entn)
  (setq cmd (getvar "CMDECHO"))
 ;; (setq OFOK 1)
 ;; (setq ENOK 1)
 (initget 6)
 (setq off (cond ((getdist
        (strcat "\nEnter Distance <"
		(rtos (setq off
              (cond ( off ) ( 1.00 ))) 2 ) ">: "
	        )
	      )
	    )
	    ( off )
	  )
	)

;;; You dont need this now as off will always have a valie
;;;  (setq off (getdist "\noffset distance:"))
;;;  (if (= off nil)
;;;    (setq OFOK 0)
;;;  )
  
;;  (if (= OFOK 1)
  (if
    (setq ent (entsel "\nselect object to offset:"))
    
;  (if (= ent nil)
;;;    (setq ENOK 0)
;;;  )
;;  (if (and (= OFOK 1) (= ENOK 1))

    (progn
      (setq entna (nth 0 ent))
      (redraw entna 3)
      (setq ent (nth 1 ent))
      (setq pk (getpoint "\nside to offset?"))
      (setvar "CMDECHO" 0)
      (command "_.OFFSET" off ent pk)
      (command)
      (command)
      (setq entn (entlast))
      (command "_.CHANGE" entn
	       "" "_P" "_C"
	       (getvar "CECOLOR") "_LA"
	       (getvar "CLAYER") "_LT"
	       (getvar "CELTYPE") ""
      )
      (setvar "CMDECHO" cmd)
      (redraw entna 4)
    )
  )
  (princ)
)

We can also use the system variable OFFSETDIST for the default. but for now we will stick with the above approach

HTH

 

 

0 Likes
Message 5 of 6

Anonymous
Not applicable
Thank you very much pbejse, it works like a treat.
0 Likes
Message 6 of 6

pbejse
Mentor
Mentor

@Anonymous wrote:
Thank you very much pbejse, it works like a treat.

Good for you, hope you learned from it as well

You are welcome @Anonymous 

 

 

0 Likes