Python Script stretch not working properly

Python Script stretch not working properly

Logesh_MarimuthuGJ3SM
Participant Participant
300 Views
2 Replies
Message 1 of 3

Python Script stretch not working properly

Logesh_MarimuthuGJ3SM
Participant
Participant

I'm new to Python scripting and recently wrote a script for a Structure TeePost. After spending many hours on it, I managed to get most of it working correctly. However, I'm facing an issue with the parametric stretch—it’s not functioning as expected.

I've attached a video demonstrating the problem. Could you please take a look and help me resolve this?

Thanks in advance for your support!

"

from varmain.primitiv import *
from varmain.custom import *

@activate(Group="Support", Ports="1", TooltipShort="HEA100 Beam", TooltipLong="HEA100 I-Beam with Rotation Option", LengthUnit="mm")
@group("MainDimensions")
@param(D=LENGTH, TooltipShort="Pipe dia")
#@param(SS=LENGTH, TooltipShort="STRING")
@param(h=LENGTH, TooltipShort="Section height")
@param(b=LENGTH, TooltipShort="Flange width")
@param(tw=LENGTH, TooltipShort="Web thickness")
@param(tf=LENGTH, TooltipShort="Flange thickness")
@param(L1=LENGTH, TooltipShort="Beam length1")
@param(L2=LENGTH, TooltipShort="Beam length2")
@group("Options")
@param(A1=LENGTH, TooltipShort="Height")
@param(A2=LENGTH, TooltipShort="Breadth")
@param(T1=LENGTH, TooltipShort="Top thickness")

#(TESTACPSCRIPT "HEA100")
def HEA100(s, D=116.0, h=80.0, b=100.0, tw=5.0, tf=8.0, L1=1000.0, L2=500.0, rotY=1, A1=150.0, A2=200.0, T1=12.0, ID='HEA100 Beam', **kw):
# Bottom flange

Flange1 = BOX(s, L=(L1-(tf+T1)), W=b, H=tf)
Flange1.rotateX(90)
Flange1.translate((0.0,0.0,2.0))
Flange2 = BOX(s, L=(L1-(tf+T1)), W=b, H=tf)
Flange2.translate(((h+tf),0.0,0.0))
Flange2.rotateX(90)
Flange2.translate((0.0,0.0,2.0))
web = BOX(s, L=(L1-(tf+T1)), W=tw, H=h)
web.translate(((h+tf)/2,0.0,0.0))
web.rotateX(90)
web.translate((0.0,0.0,2.0))
plate = BOX(s, L=A1, W=A2, H=T1)
plate.rotateY(90) #  rotate 90° along Y-axis
plate.translate(((h+tf)/2,0.0,(0-L1/2)+(T1)/2))
Flange1A = BOX(s, L=L2, W=b, H=tf)
Flange1A.rotateZ(90)
Flange1A.rotateX(90)
Flange1A.translate(((h+tf)/2,0.0,(L1/2+tf/2)-(h+2*tf)))
Flange2A = BOX(s, L=L2, W=b, H=tf)
Flange2A.rotateZ(90)
Flange2A.rotateX(90)
Flange2A.translate(((h+tf)/2,0.0,(L1/2-tf/2)))
#Flange2A.rotateX(90)
webA = BOX(s, L=L2, W=tw, H=h)
webA.rotateY(90)
webA.rotateZ(90)
webA.translate(((h+tf)/2,0.0,(L1/2)-(h/2+tf)))
#OD=CYLINDER(s, R=D/2, H=0.5, O=D/2-.1)
#OD.rotateX(90)
#OD.translate(((h+tf)/2, 0,(L1/2)+D/2))
#SS = (L1/2+T1)
s.setPoint((((h+tf)/2, 0.0,(L1/2)+D/2)), (0.0, -1.0, 0.0))
s.setLinearDimension('L1', (0, 0, 0), (0, 0, -L1))"

 

0 Likes
Accepted solutions (1)
301 Views
2 Replies
Replies (2)
Message 2 of 3

EddyWagner
Advocate
Advocate
Accepted solution

Hello @Logesh_MarimuthuGJ3SM ,

I don’t have much experience with the Python side of supports, so I’m not sure I can give you precise guidance. But from what I saw, it looks like you’re calculating the height of your support divided by 2. The insertion point of your support should be at the base, and everything you build should start from that "zero" point.

The code you posted seems off — it draws something very different from what you showed in the video. Here’s what it generated for me:

EddyWagner_0-1751974639467.png

 

This is how your base should ideally look — it should start from a fixed point that makes sense. In my opinion, the base point of the support is the best reference, like in this image:

EddyWagner_1-1751974682849.png

That way, you place it on the floor and “stretch” it up to the pipe.

 

Some people will say the “zero” point should be the connection to the pipe. That’s not wrong, but it’s harder to control, because you'll always have to manage it based on the pipe's diameter.

EddyWagner_2-1751974767624.png

In the example above, that approach would work as you described — extending the support from the base while keeping it attached to the pipe.

 

In my opinion, Plant 3D is not ideal for support modeling... but that’s another topic. I just don’t see the need to link the support directly to the pipe — there are other ways to establish that relationship. But that’s up to you.

 

One thing is certain, though: you shouldn’t create the support centered in the middle of its geometry — you’ll lose control over it.

EddyWagner_3-1751974816380.png

If you do it that way, it will always “grow” in both directions.

This center alignment is only ideal for valves and fittings where you actually need it.

 

I hope this helped!

Best regards,

Eddy

0 Likes
Message 3 of 3

Phil-22
Advocate
Advocate

Hi,

I'm not going to greatly disagree with what Eddy wrote. I'd offer though that a pipe support should come from the pipe support spec, and as a pipe support spec, it is intended to connect to ... well ... pipe. Purpose of having the support connected to the pipe is so that when extracted from P3D the information become available and useful for stress engineers to know where supports exist. So I'd suggest building from pipe outwards.

I've not tested your code, but having authored many of my own supports, I compared yours to mine and found one key-word missing which I believe makes a world of difference. Ask4Dist. If you add this to your L1 parameter definition I believe it will help you.

I've attached a few snips from one of my parametric supports - a clevis hanger. I have two key dimensions which are designer-influenced on-screen. Dimension L13 is the distance from top of steel to center of pipe, and dimension L14 is the readi-rod length. All other dimension for the clevis are catalog-driven. The nodes created a L13 and L14 may both be independently dragged on-screen to adjust their values. While the distance from top of steel to center of pipe will dictate the length of rod required, I needed to have a separate variable to provide the rod-length to the designer on-screen (for MTO purposes). When the L13 & L14 nodes overlap - the support is set. The result is a calculated rod length to reach the distance, and a correct graphic. Hoping this may help you on your path.

Cheers,

Phil