The Material Function in Dynamic Components

The Material Function in Dynamic Components

Postby Goele » Fri Feb 13, 2015 1:46 pm

Hey Guys,

Here is another question.

I'm creating a dynamic component. It is just a square face.
You can scale this square in 2D.

What I would like to do with this square:

- Choose between 3 materials in component options --> Check:
I made an attribute named color. Users can choose from a list: Blue, Red, Green. They have the following values: 1, 2 ,3

Formula for attribute Material:

This works. When I choose a color, the material changes.

- Next thing causes a bit of a problem. I would like to calculate the area for this material. I used this formula: =(FACEAREA(Material)/1000)
Material refers to the first formula so if the color is blue, It should read

This formula normaly works. But, since I am using the Material attribute, the area is now '0'.
I think it is caused by the fact that the Material Attribute paints both sides of this face and it subtracts one side of the other to calculate the area. I only want one side in this color. But how do I do that?

I'm not sure if this problem is clear. Please ask for more details if it isn't. :)
You can download the component from warehouse.



Re: The Material Function in Dynamic Components

Postby Goele » Tue Feb 17, 2015 1:11 pm

Still haven't figured this out.. Anyone who can help? :)


Re: The Material Function in Dynamic Components

Postby TIG » Tue Feb 17, 2015 2:26 pm

Your issue is this... :shock:
The rectangular face inside the DC has no materials at all == <default>.
Use Entity Info on the internal face [edit the DC] to see that.
When you change the DC's "Material" it applies to the DC instance itself.
So when you get Entity Info on the DC itself it's say "Red".
But the internal face with no material <default> which are inside a component [or group] 'display' the material of that container - the face's material does NOT change from <default>.
So although a face might 'look' "Red", it actually has no material at all <default>.
Your DC code looks for all faces colored "Red" inside the DC component, BUT there are NONE, because the actual face has the <default> material - so you correctly get Area=0.

You can fix the DC code to report the face's area by using Area as =FACEAREA()/2
Note /2 *** to consider just the one side !
Now that DC always reports the Area of the internal face***.
In your current DC the Area is returned, and you have its Material of say "Red" etc.

BUT if you have a "Red" material actually painted on to the face itself [one side], then the code =FACEAREA(Material) will work IF the chosen Material is "Red" - giving Area=12345... - otherwise it's Area=0 - as if another color is chosen there are no "Blue" or "Green" faces, so then the DC's chosen Material returns Area=0 again...

In DC code you cannot assign a material to a face, only to a 'container' - component-instance or group.
You can change the way a face 'appears', because any faces using the <default> material displays using the container's material, but its material is still <default>.
User avatar
Global Moderator

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Ad Machine 


Return to Dynamic Components

Who is online

Users browsing this forum: No registered users and 2 guests

Visit our sponsors: