Support Forum

[Frage] How to put a calculated value in the pyp value?

Schlagworte:
  • PythonParts
  • PYP

hello everyone

As shown in the picture, I want to set the initial value as the Length/Count value in the Width value.

How can I set the calculation value to the Width value?

Anhänge (1)

Typ: image/jpeg
93-mal heruntergeladen
Größe: 70,07 KiB

Hilfreichste Antwort anzeigen Hilfreichste Antwort verbergen

Hi.

In the pythonscript you should be able to set values like this:

self.build_ele.width.value = str(self.l/1000)

The correct definition depends on how your code looks like.

name_of_parameter.value = calculated_value

Update:
changed length to width

VG
Marcus

Hi.

In the pythonscript you should be able to set values like this:

self.build_ele.width.value = str(self.l/1000)

The correct definition depends on how your code looks like.

name_of_parameter.value = calculated_value

Update:
changed length to width

VG
Marcus

Zitiert von: Marcus
Hi.
In the pythonscript you should be able to set values like this:
self.build_ele.width.value = str(self.l/1000)

The correct definition depends on how your code looks like.name_of_parameter.value = calculated_value
Update:
changed length to width

Thanks for answering my question.

However, what I am curious about is how to put the initial value of Width into the calculation formula(build.W1.value / build.Count.value).

As shown in the picture, when you run Library in Allplan, you want to set the initial value.

I leave all my Python, PYP, Allplan capture images. Thanks again for your help.

Anhänge (3)

Typ: image/jpeg
27-mal heruntergeladen
Größe: 89,76 KiB
Typ: image/jpeg
47-mal heruntergeladen
Größe: 53,53 KiB
Typ: image/jpeg
42-mal heruntergeladen
Größe: 101,07 KiB

The screenshot doesn't show your parameters W1 in the pyp file.

So far i haven' t used value lists. Therefore i'm not sure about how to handle those.
I think there should be some examples about value list parameters in the example folder.
(Assuming they give you a list of values?)

VG
Marcus

Hello,

the initial value in the pyp-file is always a constant value.

Why do you want to have this initial value as Length/Count?

Best regards
Horst

Zitiert von: Horst_Hohmann
Hello,
the initial value in the pyp-file is always a constant value.
Why do you want to have this initial value as Length/Count?
Best regards

Horst

I am manufacturing the coping part of a pier, and I want to divide the upper part of the coping according to the number of girders.
For example, if there are three girders, I wanted to divide the coping into three equal parts along the length of the coping. So, I wanted to divide the initial value by the number of girders over the total length.

Hello,

but you also wont to have the possibility to modify this values?

Best regards
Horst

Yes.

I want to set the calculated value only as the initial value and modify the value.

Hello,

you can set the default value as you have done in the pyp-file. Then you can implement the function

def modify_element_property(build_ele: BuildingElement,
                            name     : str,
                            value    : Any):
    """
    Modify property of element

    Args:
        build_ele:  the building element.
        name:       the name of the property.
        value:      new value for property.

    Returns:
        True/False if palette refresh is necessary
    """

In this function you can check the name for an input of Count or Length and adapt the Width values accordingly.

Best regards
Horst