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: 

Parametric Piping Supports with Python

22 REPLIES 22
Reply
Message 1 of 23
jabowabo
4950 Views, 22 Replies

Parametric Piping Supports with Python

A couple of examples of supports created with Python scripts: http://m.youtube.com/watch?v=JPEjYIZPnK8

I used Scott Hallmarks excellent blog post here to get started: http://bit.ly/1cnS8lf

Tags (2)
22 REPLIES 22
Message 2 of 23
howard.gardener
in reply to: jabowabo

Hi,

 

I'm attemping to add 2 addition port to an Orifice flange and rotate the port 45deg around the flange OD.

Creating the graphics is pretty straight forward but i'm having dificulties defining the the addition ports and rotating the port 45 deg, see attached.

Inline ports 1 & 2 (FL & BV) are fine... Port 2 & 3 (THDF) seems to be define at angles 0 and 180 respectively. I've defined the additional port in the script and in the catalog, but they are not showing up in the parametric.

Any help would be greatly appreciated.

Message 3 of 23
jabowabo
in reply to: jabowabo

Hard to tell what the issue is without the script. Can you post it?
Message 4 of 23
howard.gardener
in reply to: jabowabo

Hi Jabowabo,

 

Here is the script.

Message 5 of 23
jabowabo
in reply to: howard.gardener

Your points and vectors for the connections are a little wonky.  This should get you close to what you want for your connectors:

 

    s.setPoint((0.0, 0.0, 0.0), (-1.0, 0.0, 0.0), 0.0)
    s.setPoint((L, 0.0, 0.0), (1.0, 0.0, 0.0), 0.0)


    s.setPoint((IL, (D1 / 2.0 - II) * cos(0.785398163), (D1 / 2.0 - II) * sin(0.785398163)), (0.0, 1.0, 1.0), 0.0)
    s.setPoint((IL, -(D1 / 2.0 - II) * cos(0.785398163), (D1 / 2.0 - II) * sin(0.785398163)), (0, -1.0, 1.0), 0.0)

    s.setPoint((IL, (D1 / 2.0 - II) * cos(0.785398163), -(D1 / 2.0 - II) * sin(0.785398163)), (0.0, 1.0, -1.0), 0.0)
    s.setPoint((IL, -(D1 / 2.0 - II) * cos(0.785398163), -(D1 / 2.0 - II) * sin(0.785398163)), (0, -1.0, -1.0), 0.0)

 

Message 6 of 23
howard.gardener
in reply to: jabowabo

Thank so so very much! It works perfectly. I'm very new at this and still haven't got my head around the setPoints yet.

I'll have to break down what you've done to fully understand it, but thanks again, much appreciated.

Message 7 of 23
roy
Participant
in reply to: jabowabo

Hi,

 

After watching your video are you able to explain how you associated your grips with the associated variables in your script so that the support would extend to the vessel wall?

I am working on a number of custom supports and want to be able to vary the support height to account for sloping pipe in pipe racks.

I have attached the one of the scripts I have produced, which so far which functions as I want in all other respects. I am using 'B' as the variable to initialy set the dimension from the bottom of pipe to the base of the support.

 

Thanks,

Roy

Message 8 of 23
jabowabo
in reply to: roy

This is the line that sets the grip locations and stretch properties:

	s.setLinearDimension('B',(0, 0, -R), (0, 0, -(B+OD/2)))

 Try changing it to this and see if you get what you want:

	s.setLinearDimension('B',(0, 0, -R1), (0, 0, -(B+R1)))

 

Message 9 of 23
roy
Participant
in reply to: jabowabo

Hi again,

 

Thanks for looking at the script and locating the errors pointed out. After adjusting the script I am still unable to use the grip to adjust the height of the shoe however. Looking at the comand window I receive the following message.

 

"Geometry can not be generated with the given parameters.
Can't find symbol for specified part."

 

This is what I would expect from a calculation or coding error and should show up when running a Testacpscript comand. The program how ever geneates the item and only errors if I try to change a parameter value of the created item.


The same message is received if I type in a new value in the Properties window under the Dimensions sub heading. In fact, it happens if I try to change any of the values in the Dimensions sub heading.

 

I am begining to wonder if its a pathing issue when part being altered looks back to the creation script to see how it was made. The script is currently located in the following directory as directed by the little Autodesk University documentation I have been able to find.


C:\AutoCAD Plant 3D 2015 Content\CPak Common\CustomScripts

( http://aucache.autodesk.com/au2011/sessions/4214/datasets/v1_PD4214-L_Radhakrishnan_AnnexB_Custom%20... Page 46 note 3 )

 

Are you storing your scripts in the above location or at some other location such as in the VARIANTS.ZIP file under CPAK Common? I ask this as other documentation I have found online refers to decompiling existing scripts and restoring the altered script to the original locations.

 

Thanks,

 

Roy

Message 10 of 23
jabowabo
in reply to: roy

I haven't had time to look too close at your script but I think your problem has to do with your calculations not working with the modified 'B' length. Try going through the script and substituting a value that fails when modifying the item.
Message 11 of 23
roy
Participant
in reply to: jabowabo

Thanks for looking at this. After checking the script again I did find a couple of dimensional placement errors with the guide placement but nothing that would affect the grips operation.

 

In an effort to eliminate the need to check the entire script again I wrote a simple test script to see if my issues reoccured when starting from scratch. The test script consists of a box translated to the base of the pipe section. I then associated the setLinearDimension with the box height value BH.

I still have the same issues with not being able to stretch with the grip.

Hopefully this will make the problem more obvious.

 

The test script is attached. 

 

Thanks,

Roy

Message 12 of 23
roy
Participant
in reply to: roy

Quick update,

I managed to get the attached script to work as I wanted.

I added an Ask4Dist flag to the BH parameter definition and increased the point acuracy of the variable definitions after setting them nomially to 1.000000 as a place holder value.

I set the desired dimentions for the finished items in the catalog editor.

I now will look harder at my other scripts now that I have have at least got the basics to work.

 

Thanks.

 

Message 13 of 23
howard.gardener
in reply to: jabowabo

Hi again,

 

I've been doing a little scripting and was wondering if it is possible to add color to an object inside the script.

Message 14 of 23
roy
Participant
in reply to: jabowabo

Hi there,
As far as I am awear, i dont think its possible. Color settings are handled by the Plant softeware in the project properties, Plant 3D DWG Settings, Layer and Color Settings. Note that the pipe support settings are right at the bottom of the window to the left of the apply, ok etc buttons.
This makes sense, because generally if you have you settings as color by layer for a project, it would add confusion if parts you were inserting had a different color than the line they were assigned to. Basically it helps enforce consistancy in a project.
In saying that you can change the color manually once a part is inserted but it will still be a single color.
The only other option i can think of atm is in rendering if you need coloring of items for presentation pourposes.

Thanks, Roy
Message 15 of 23
howard.gardener
in reply to: roy

Thanks Roy

Message 16 of 23

Dear roy,

 

This is my script, in which i tried to use stretch command

using line 

s.setLinearDimension('H', (0, 0, 0), (0, 0, -H))

but it is not working.

Kindly guide me where i am going wrong

regards

 

import aqa.math
import math
from varmain.primitiv import *
from varmain.var_basic import *
from varmain.custom import *
@activate(Group="Support", TooltipShort="Single clamp saddle", TooltipLong="sliding support", LengthUnit="mm",Ports="1")
@group("MainDimensions")
@param(D=LENGTH, TooltipShort="Diameter")
@param(H=LENGTH, TooltipShort="Height of Saddle", Ask4Dist=True)
@group(Name="meaningless enum")
@enum(1, "align X")
@enum(2, "align Y")
@enum(3, "align Z")
#(arxload "PnP3dACPAdapter")
#(TESTACPSCRIPT "KRS1")
#-------------------------------------------------------------------
def TESTSTRE(s, D = 57.0, H=112.0, ID = 'TESTSTRE', **kw):
R1 = D / 2.0
o1=CYLINDER(s, R=R1, H=H, O=0.0)
s.setPoint((0.0, 0.0, 0.0), (0.0, 0.0, -1.0))
s.setLinearDimension('H', (0, 0, 0), (0, 0, -H))

Message 17 of 23

Hi again Jabowabo,

 

I've asked about the on the forum, but haven't had a response from anyone. my question is in 3 parts.

First.

I've created custom parametric in the past that needed one of their parameter adjusted after insert from the spec. In the past I've added the "Custom" designator to the Component Designation field in the spec which usually works, but for some reason does not with this script, see attached.

If  I change the group from valve to (@activate(Group="Elbow") it works fine but not with "Valve". Is Valve the correct group name for custom valves?

 

Second:

After see your code for the Vessel Pipe Guide I'm wondering if changing the Component Designation is the best way to adjust components after placement in the model. I've tried following your example but have not been successful, please advise.

 

Third.

I've created a custom valve actuator but I am not able to see it in the list of Operator shape when attempting to add it to a valve, see script attached.

If I can't add additional parametric shape is it possible to customize the existing ones.

 

 Thanks in advance for any help you can give my questions.

 

Howard

Message 18 of 23
jabowabo
in reply to: reccaddsupport

1. I haven't attempted exactly what you are trying yet so I can't confirm. Seems like 'Valve' ought to work though.  I think 'CUSTOM' is case sensitive so you may check that. I don't see your script attached so hard to know what other problem may exist.

2. The only way I have been able to use the stretch grips is with Supports.

3. This is a known issue - see here for operator info.

Message 19 of 23
izabela_dreksler
in reply to: jabowabo

Hi,

 

could you tell me how the option "Ask4Dist=True" works?

 

Is it possible to use it to make a valve with custom face-to-face dimension?

 

Regards,

Message 20 of 23
jabowabo
in reply to: izabela_dreksler

Per the documentation: "(Ask4Dist) that tells us its length may also be given by specifying a distance in the model."

 

I'm actually not sure this works at all as I haven't seen that it makes any difference. When we want to modify dimensions for items, we convert to a custom part which allows for modifying dimensions.

 

 

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

Post to forums  

Autodesk Design & Make Report

”Boost