Jump to content

Need Help ..To find Values Between Greater value and Less Value


Recommended Posts

Posted


(defun c:Test ()
 (setq grt (getreal "\nEnter Greater Then Value:")); "101"
 (setq less (getreal "\nEnter Less Then Value:"));"102"
 (setq ss (ssget))
 (setq cntr 0)
 (repeat (sslength ss)
   (setq ssnme (ssname ss cntr))
   (setq ent (entget ssnme))
   (setq value (atof (cdr (assoc 1 ent))))
   (if	(and (< value less) (> value grt))
     (command "Chprop" ssnme "" "c" "2" "")
     (command "chprop" ssnme "" "c" "3" "")
   )
   (setq cntr (1+ cntr))
 )
)

 

 

i want to change color in between 101 and 102 value

101.233

101.455

101.786

101.322

 

sorry for my poor english tank u

Posted

First, please pay attention that the color is stored under DXF code 62, not 1. Also, there is one exception - when the color is attached as ByLayer. Then the code 62 isn't available and you will need to check the color of container layer (DXF code 8).

Posted

yes its working now

 

Tankq Msasu

 

:)

Posted

You may want to try:

 

[b][color=BLACK]([/color][/b]defun c:test [b][color=FUCHSIA]([/color][/b]/ grt less ss en ed cl[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq grt [b][color=NAVY]([/color][/b]getreal [color=#2f4f4f]"\nGreater Than Value:   "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not less[b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]<= less grt[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]initget 1[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq less [b][color=MAROON]([/color][/b]getreal [color=#2f4f4f]"\nLess Than Value:  "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]setq en [b][color=GREEN]([/color][/b]ssname ss 0[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]setq ed [b][color=GREEN]([/color][/b]entget en[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]or [b][color=GREEN]([/color][/b]setq cl [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 62 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                 [b][color=GREEN]([/color][/b]setq cl 256
                       ed [b][color=BLUE]([/color][/b]append '[b][color=RED]([/color][/b][b][color=PURPLE]([/color][/b]62 . 256[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]entmod [b][color=GREEN]([/color][/b]subst [b][color=BLUE]([/color][/b]cons 62 [b][color=RED]([/color][/b]if [b][color=PURPLE]([/color][/b]<= grt cl less[b][color=PURPLE])[/color][/b] 2 3[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                            [b][color=BLUE]([/color][/b]assoc 62 ed[b][color=BLUE])[/color][/b] ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]ssdel en ss[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

 

It gives you:

  • some basic input error checking
  • testing for equal values
  • (entmod) in lieu of (command)
  • BYLAYER inclusion

 

-David

Posted

Are you looking to change the colour based on the content of selected Text?

 

If so, consider:

 

(defun c:test ( / cl dx en gt in lt ss vl )
   (if
       (and (setq lt (getreal "\nSpecify Lower Bound: "))
           (progn
               (while
                   (and
                       (setq gt (getreal "\nSpecify Upper Bound: "))
                       (< gt lt)
                   )
                   (princ (strcat "\nUpper Bound must be greater than " (rtos lt)))
               )
               gt
           )
           (setq ss (ssget "_:L" '((0 . "TEXT") (1 . "*#*"))))
       )
       (repeat (setq in (sslength ss))
           (setq en (entget (ssname ss (setq in (1- in)))))
           (if (setq vl (distof (cdr (assoc 1 en))))
               (progn
                   (if (< lt vl gt)
                       (setq cl '(62 . 2))
                       (setq cl '(62 . 3))
                   )
                   (if (setq dx (assoc 62 en))
                       (entmod (subst cl dx en))
                       (entmod (append en (list cl)))
                   )
               )
           )
       )
   )
   (princ)
)

Posted

i want to change color in between 101 and 102 value

101.233

101.455

101.786

101.322

 

I guess those values are just an example :)

 

FWIW: Quick mod for the code you posted,

 

(defun c:Test  ( / grt less ss cntr str)
     (setq grt (getreal "\nEnter Greater Then Value:")) 
     (setq less (getreal "\nEnter Less Then Value:"))   
     (setq ss (ssget [color=blue]"_:L" '((0 . "*TEXT"))))[/color]
     (setq cntr 0)
     (repeat (sslength ss)
           (setq ssnme (ssname ss cntr))
           (setq ent (entget ssnme))
          [color=blue](setq str (cdr (assoc 1 ent)))[/color]
          [color=blue](if (numberp (setq value (read str)))[/color]
[color=blue]              (entmod (append  ent (list (cons 62 (if (< grt value less)[/color]
[color=blue]                       2 3)))))[/color]
[color=blue]                           )[/color]
           (setq cntr (1+ cntr))
           )(princ)
     )

Posted
Are you looking to change the colour based on the content of selected Text?

 

Thats is what i had in mind too Lee

 

(setq ss (ssget "_:L" '((0 . "TEXT") (1 . [color=blue]"*#*"[/color]))))....

 

I keep forgetting about that filter :lol: ...

Posted

Tank u Guys ..........

 

Thanx for Your Support

 

:D

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