2011/2/3 Vladimir Everstov <vovan_...@mail.ru>

>  Hello there!
>
> I am trying to use PAF in my work and i am wondering is it possible to
> structure parameters as lists and is there way to create parameters
> programmatically? In sample files I couldn't find how to create parameters
> programmatically and I was thinking is it possible to have several
> parametric modeling contexts?
>
> Best regards Vladimir Everstov
>
>
Hi Vladimir,

It's possible to have concurrent parametric modeling contexts: look at the
script 'multi_context.py' located in the /Level2/PAF folder of pythonOCC-0.5
examples.

The parameters can be created 'automatically'. Actually, a parameter is a
property of the Parameters class. Creating the parameter 'X1' with the value
12 can be achieved with:
p.X1 = 12 (it the 'manual' method').

But you can also use the following:
setattr(p,'X1',12)

Sor, if you want to create n parameters 'X1','X2','X3' ...,'Xn' from a list,
you can use the following function:
<python_code>
def make_n_parameters(my_list):
    index = 1
    for elem in my_list:
        setattr(p,'X%i',elem)
        index +=1

make_n_parameters([1,12,14,15.6,17])
</python_code>

If you want to access to a 'list' of parameters, use the keys of the
properties dict:
<python_code>
a = p.GetAllParameters().keys()
print a
</python_code>
In [45]: a = p.GetAllParameters().keys()
In [46]: print a
-------> print(a)
['Y', 'X10', 'X8', 'X9', 'X2', 'X3', 'X1', 'X6', 'X7', 'X4', 'X5']

<python_code>
for param_name in a:
    print getattr(p,param_name)
</python_code>

Note however that the PAF was not designed to deal with hundreds or
thousands of parameters. It's rather intended to base the design upon a
small set of parameters that drive the shape. Hope it helps anyway,

Best regards,

Thomas
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to