Jump to content
brandalf_the_semiGray

Boolean logic to change color of objects?

Recommended Posts

brandalf_the_semiGray

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.

Share this post


Link to post
Share on other sites
brandalf_the_semiGray

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

Share this post


Link to post
Share on other sites
ronjonp

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.

Share this post


Link to post
Share on other sites
brandalf_the_semiGray

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

Share this post


Link to post
Share on other sites
ronjonp

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

 

Share this post


Link to post
Share on other sites
brandalf_the_semiGray
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

Share this post


Link to post
Share on other sites
ronjonp
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

Share this post


Link to post
Share on other sites
dlanorh

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

Share this post


Link to post
Share on other sites
Grrr
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

Share this post


Link to post
Share on other sites
ronjonp
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!

Share this post


Link to post
Share on other sites
Grrr
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:

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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