AutoCAD Plant 3D Forum
Welcome to Autodesk’s AutoCAD Plant 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Plant 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Plant3D Python libraries assessment

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
KBA9XP4Y
478 Views, 2 Replies

Plant3D Python libraries assessment

Hello 

 

I am trying to make a custom pipe support catalog for Plant3D but facing some issues.

I want to use the following libraries: 

 

from varmain.primitiv import *
from varmain.custom import *
from aqa.math import *
 
But it seems I can`t use them
KBA9XP4Y_0-1710253541404.png

 

All library files are placed in C:\AutoCAD Plant 3D 2021 Content\CPak Common

 

My script looks as follows: 

from aqa.math import *
from varmain.primitiv import *
from varmain.custom import *
 
@Anonymous(Group="Supports", TooltipShort="Ground Support", TooltipLong="A ground support structure with H80 profiles", LengthUnit="mm")
@group("MainDimensions")
@Anonymous(H=LENGTH, TooltipShort="Height", DefaultValue=1000)
@Anonymous(W=LENGTH, TooltipLong="Width", DefaultValue=2200)
@Anonymous(Profile=STRING, TooltipShort="Profile Type", DefaultValue="H80")

def GROUNDSUPPORT(s, H=1000, W=2200, Profile="H80", **kw😞
    # Calculate the width and thickness based on H80 profile assumptions
    profile_width = 80  # Assuming H80 profile width is 80mm
    profile_thickness = 8  # Assuming H80 profile thickness is 8mm
   
    # Create the two vertical legs
    leg1 = BOX(s, L=profile_width, W=profile_thickness, H=H, O=(-W/2 + profile_width/2, 0, H/2))
    leg2 = BOX(s, L=profile_width, W=profile_thickness, H=H, O=(W/2 - profile_width/2, 0, H/2))
   
    # Create the horizontal crossing member
    crossing = BOX(s, L=W, W=profile_width, H=profile_thickness, O=(0, 0, H - profile_thickness/2))
   
    # Combine all parts into one structure
    structure = leg1.uniteWith(leg2)
    structure.uniteWith(crossing)

    return structure
2 REPLIES 2
Message 2 of 3
matt.worland
in reply to: KBA9XP4Y

Hello @KBA9XP4Y

Those warnings can be ignored. If you are using Pylance in VSCode, you will get false warnings. Plant 3D's Python is a subset/altered version of the full Python install, and Pylance doesn't know about all of Plant 3D's code.

You do have an error in your code when creating your boxes. You have an additional parameter that is not part of the Box method.

Works
leg1 = BOX(s, L=profile_width, W=profile_thickness, H=H)
Doesnt Work
leg1 = BOX(s, L=profile_width, W=profile_thickness, H=H, O=(-W/2 + profile_width/2, 0, H/2))

 

From the help file

BOX defines a box
a call from Python should be like
   s=BOX(s, L, W, H)
The parameters means:
   s the main object
   L the box length
   W the box width
   H the box height

I don't know what your O parameter is supposed to do, but you will have to do it differently.

If my reply was helpful, please give a "Thumbs Up" or "Accept as Solution"
Message 3 of 3
KBA9XP4Y
in reply to: KBA9XP4Y

It worked for me. Thanks a lot for your help

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report