design-automation / mobius-parametric-modeller

Möbius for parametric modelling.
https://design-automation.github.io/mobius-parametric-modeller/
MIT License
10 stars 6 forks source link

functions with attribute index #619

Open phtj opened 4 years ago

phtj commented 4 years ago

For functions with attrib index, the index is only used for attributes that are lists Its is quite annoying because it is often null

Instead, we can use an attribute name with index included as part of the string

For example

attrib.Set(my_posis, "xyz[2]", 123)

instead of

attrib.Set(my_posis, "xyz", 2, 123)

phuongtung1 commented 4 years ago

i think this might not be possible, since the index could be a variable. So if we want to set xyz[i], the string would be "xyz[i]" which is not possible to solve in the modeling function since the value of i is not passed in

phtj commented 4 years ago

We can use an array instead, where the first item is the attrib name and the second is the attrib index. But in cases where there is no name, we just pass a string (no array).

For example

attrib.Set(my_posis, ["xyz", 2], 123)

instead of

attrib.Set(my_posis, "xyz", 2, 123)

The reason for this is that most of the time, there is no index, so we can do

attrib.Set(my_posis, "my_attrib", 123)

instead of

attrib.Set(my_posis, "my_attrib", null, 123)