Support Forum

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


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?

Attachments (1)

Type: image/jpeg
Downloaded 91 times
Size: 70,07 KiB

Show most helpful answer Hide most helpful answer

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

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

Attachments (3)

Type: image/jpeg
Downloaded 27 times
Size: 89,76 KiB
Type: image/jpeg
Downloaded 47 times
Size: 53,53 KiB
Type: image/jpeg
Downloaded 42 times
Size: 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

Quote by 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


https://connect.allplan.com/ uses cookies  -  More information

Accept