Jump to content

Boolean logic to change color of objects?


Recommended Posts

Posted

Is it possible to use an if statement of some sort to alter the color of an object in a block? A block I'm making has a bunch of slope data, and based on that slope data I want to change the color of an object to symbolize a pass/fail of sorts.

 

Thanks in advance for any input.

Posted

I'm leaning towards using vla objects at this point.

Posted

Your post is very vague. Perhaps post a sample drawing of before and after of what you're looking for.

 

Short answer is yes .. if statements are very common. The part we're missing about your post is the actual logic required to determine what a pass fail is.

Posted

Sorry about that. I'm not at a place where I have a drawing completed just yet, but I can post one when I have something like what I'm aiming for

 

I want to supply a routine with upper and lower bounds for slope values. Then, based on the slope values of individual blocks, change the color of a circle in the middle of each block.

 

For example:

 

if(all slopes are in bounds) turn circle green, else turn circle red

Posted

Here is a simple example of checking if a number is within a range:

(defun _inrange (n ln un) (<= ln n un))
(vla-put-color
  o
  (if (_inrange 2 1 2)
    3
    1
  )
)

 

Posted (edited)
24 minutes ago, ronjonp said:

Here is a simple example of checking if a number is within a range:


(defun _inrange (n ln un) (<= ln n un))
(vla-put-color
  o
  (if (_inrange 2 1 2)
    3
    1
  )
)

 

Would you be willing to explain the function argument syntax for me? I'm very new to this and not familiar. Thank you

 

EDIT: wait i think i figured it out. The (<= ln n un) could be the one line of the code for the function while the (n ln un) are the arguments correct?

Edited by brandalf_the_semiGray
Posted
54 minutes ago, brandalf_the_semiGray said:

EDIT: wait i think i figured it out. The (<= ln n un) could be the one line of the code for the function while the (n ln un) are the arguments correct?

That is correct :)

n = number to check

ln = low range number

un = upper range number

  • Thanks 1
Posted

If you make the circle color by block and everything else bylayer the changing the color of the block will change the color of the circle whilst everything else remains the same

Posted
On 12/3/2019 at 5:29 PM, ronjonp said:

Here is a simple example of checking if a number is within a range:


(defun _inrange (n ln un) (<= ln n un))
(vla-put-color
  o
  (if (_inrange 2 1 2)
    3
    1
  )
)

 

 

(setq _inrange <=)

(_inrange 2 1 2) >> nil
(_inrange 1 2 3) >> T

:lol:

  • Like 1
Posted
On 12/7/2019 at 2:24 PM, Grrr said:

 


(setq _inrange <=)

(_inrange 2 1 2) >> nil
(_inrange 1 2 3) >> T

:lol:

:) .. there is also that!

Posted
1 minute ago, ronjonp said:

:) .. there is also that!

 

duh, apologies - I didn't realised that you changed the position of the arguments, due my setq is not the same as your defun.

:facepalm:

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