Custom Python Scripts For AutoCAD Plant 3D Part 5 - AutoCAD DevBlog
Custom Python Scripts For AutoCAD Plant 3D Part 5 - AutoCAD DevBlog
Custom Python Scripts For AutoCAD Plant 3D Part 5 - AutoCAD DevBlog
01/21/2016
This article will look at creating a nozzle to use in the nozzles catalog
which AutoCAD Plant 3D equipment loads when putting nozzles on
equipment.
1 of 9 4/03/2017 12:49 AM
Custom Python Scripts for AutoCAD Plant 3D Part 5 - AutoCAD... http://adndevblog.typepad.com/autocad/2016/01/custom-python...
@activate(Group="StraightNozzle,Nozzle", Tooltip
Short="Long Weld Neck", TooltipLong="Long Weld N
eck", LengthUnit="in", Ports="2")
@group("MainDimensions")
@param(D10=LENGTH, TooltipShort="Nominal Outside
Diameter",TooltipLong="Nominal Outside Diameter"
)
@param(L1=LENGTH, TooltipShort="Overall Length."
, TooltipLong="Overall Length")
@param(L2=LENGTH, TooltipShort="Hub Length", Too
ltipLong="Length of flange with weld neck.")
@param(OF=LENGTH, TooltipLong="Length between co
nnection points.")
@param(B1=LENGTH, TooltipLong="Flange Thickness"
)
@param(D12=LENGTH, TooltipLong="Flange OD Width"
)
@param(D13=LENGTH, TooltipLong="OD of Weld neck"
)
2 of 9 4/03/2017 12:49 AM
Custom Python Scripts for AutoCAD Plant 3D Part 5 - AutoCAD... http://adndevblog.typepad.com/autocad/2016/01/custom-python...
Metadata
First we have the includes, this script the includes section is particular
important because we are using some of the stock flange scripts
(flangesub, pipesub).
# Embedded file name: varmain\pipesub\cpp_f_f_.py
c
from aqa.math import *
from varmain.flangesub.cpfwo import *
from varmain.pipesub.cpp_util import *
from varmain.primitiv import *
from varmain.var_basic import *
from varmain.custom import *
Second is the section declaring our tooltips and parameters. One the
first line here, because we want the script listed under the
StraightNozzle and Nozzle categories, we include both.
@activate(Group="StraightNozzle,Nozzle", TooltipS
hort="Long Weld Neck", TooltipLong="Long Weld Nec
k", LengthUnit="in", Ports="2")
@group("MainDimensions")
@param(D10=LENGTH, TooltipShort="Nominal Outside
Diameter",TooltipLong="Nominal Outside Diameter")
@param(L1=LENGTH, TooltipShort="Overall Length.",
TooltipLong="Overall Length")
@param(L2=LENGTH, TooltipShort="Hub Length", Tool
tipLong="Length of flange with weld neck.")
@param(OF=LENGTH, TooltipLong="Length between con
nection points.")
@param(B1=LENGTH, TooltipLong="Flange Thickness")
@param(D12=LENGTH, TooltipLong="Flange OD Width")
@param(D13=LENGTH, TooltipLong="OD of Weld neck")
3 of 9 4/03/2017 12:49 AM
Custom Python Scripts for AutoCAD Plant 3D Part 5 - AutoCAD... http://adndevblog.typepad.com/autocad/2016/01/custom-python...
(http://adndevblog.typepad.com
/.a/6a0167607c2431970b01b7c80ac6e9970b-pi)
StraightNozzles
(http://adndevblog.typepad.com
/.a/6a0167607c2431970b01b7c80ac6f3970b-pi)
Nozzle class shown by clicking advanced shape options and selecting
nozzle.
Testing
To test the script, I made a tool palette icon with this in the macro
portion:
^C^CPLANTREGISTERCUSTOMSCRIPTS;^C^C(command "arx" "l"
"Pnp3dacpadapter");(testacpscript "nozflange");
4 of 9 4/03/2017 12:49 AM
Custom Python Scripts for AutoCAD Plant 3D Part 5 - AutoCAD... http://adndevblog.typepad.com/autocad/2016/01/custom-python...
(http://adndevblog.typepad.com
/.a/6a0167607c2431970b01b8d194d5c3970c-pi)
(http://adndevblog.typepad.com
/.a/6a0167607c2431970b01b7c80ac703970b-pi)
The default path for the nozzle catalog is "C:\AutoCAD Plant 3D 2016
Content\CPak Common\NOZZLE Catalog.acat"
To open the nozzle catalog, switch to the Catalogs tab, and go to open,
and then browse to it. Once in the catalog you can click create new
component and select your script. Fill in some sample data and save
your catalog component and the catalog. Note that for flanged
nozzles, your end type and pressure class must be set.
5 of 9 4/03/2017 12:49 AM
Custom Python Scripts for AutoCAD Plant 3D Part 5 - AutoCAD... http://adndevblog.typepad.com/autocad/2016/01/custom-python...
nozzle.
(http://adndevblog.typepad.com
/.a/6a0167607c2431970b01bb08af933d970d-pi)
You can change the nozzle orientation in the Change location tab.
(http://adndevblog.typepad.com
/.a/6a0167607c2431970b01b7c80ac712970b-pi)
Note that if you want the user to override the nozzle length, you
should use the L parameter in your script. In this case (using L1), for a
long weld neck, the catalog data will drive the length, and the user
won’t be able to change it.
Deployment
6 of 9 4/03/2017 12:49 AM
Custom Python Scripts for AutoCAD Plant 3D Part 5 - AutoCAD... http://adndevblog.typepad.com/autocad/2016/01/custom-python...
python-scripts-for-autocad-plant-3d-part-5.html)
Reza said...
Dear David,
I want to create equipment in plant 3d from predefined shape. (1 Torispheric Head,
2 Cylinder, ...)
I want to implement it in C# program.
Best Regards
Reply
02/23/2016 at 12:10 AM (http://adndevblog.typepad.com/autocad/2016/01
/custom-python-scripts-for-autocad-plant-3d-part-5.html#comment-
6a0167607c2431970b01bb08bde9de970d)
_davewolfe (http://twitter.com/_davewolfe) said...
Did you look at the samples in the 2016 Plant 3d SDK? They added an equipment
api in 2016. http://usa.autodesk.com/adsk/servlet/index?siteID=123112&
id=15460551 (http://usa.autodesk.com/adsk/servlet/index?siteID=123112&
id=15460551)
Reply
02/24/2016 at 06:05 AM (http://adndevblog.typepad.com/autocad/2016/01
/custom-python-scripts-for-autocad-plant-3d-part-5.html#comment-
6a0167607c2431970b01b7c819b13a970b)
Reza said...
Thank you for your comment. In sample code, equipment created from predefined
template (Create from package). I want to create equipment from predefined shape
like torispheric Head + cylinder + ..)
Actually I want to import PVELITE model in autocad plant 3d. I can extract
equipment shape from SQLite database of PVELITE file.
CADWorx impliment import of PVELITE in his software.
Any comment will be depreciated.
Reply
02/28/2016 at 06:23 AM (http://adndevblog.typepad.com/autocad/2016/01
/custom-python-scripts-for-autocad-plant-3d-part-5.html#comment-
6a0167607c2431970b01b8d1a57558970c)
_davewolfe (http://twitter.com/_davewolfe) said...
I think you'll have to build your own model using AutoCAD 3d solids and then
convert that to an equipment block. PV Elite can add more types with dimensional
data that doesn't correlate to the Plant 3d equipment drawing methods.
7 of 9 4/03/2017 12:49 AM
Custom Python Scripts for AutoCAD Plant 3D Part 5 - AutoCAD... http://adndevblog.typepad.com/autocad/2016/01/custom-python...
Reply
03/07/2016 at 07:34 AM (http://adndevblog.typepad.com/autocad/2016/01
/custom-python-scripts-for-autocad-plant-3d-part-5.html#comment-
6a0167607c2431970b01b8d1aa2c8f970c)
Comment below or sign in with Typepad (http://www.typepad.com
/sitelogin?uri=http%3A%2F
%2Fadndevblog.typepad.com%2Fautocad%2F2016%2F01%2Fcustom-python-
scripts-for-autocad-plant-3d-part-5.html&
fp=2416f6fe6e795b8413af6d64dbbf7e17&view_uri=http%3A%2F
%2Fprofile.typepad.com%2F&via=blogside&post_uri=http:
//adndevblog.typepad.com/autocad/2016/01/custom-python-scripts-for-autocad-
plant-3d-part-5.html) Facebook (http://www.typepad.com/sitelogin?uri=http
%3A%2F%2Fadndevblog.typepad.com%2Fautocad%2F2016%2F01%2Fcustom-
python-scripts-for-autocad-plant-3d-part-5.html&
fp=2416f6fe6e795b8413af6d64dbbf7e17&view_uri=http%3A%2F
%2Fprofile.typepad.com%2F&via=blogside&service=facebook&post_uri=http:
//adndevblog.typepad.com/autocad/2016/01/custom-python-scripts-for-autocad-
plant-3d-part-5.html) Twitter (http://www.typepad.com/sitelogin?uri=http
%3A%2F%2Fadndevblog.typepad.com%2Fautocad%2F2016%2F01%2Fcustom-
python-scripts-for-autocad-plant-3d-part-5.html&
fp=2416f6fe6e795b8413af6d64dbbf7e17&view_uri=http%3A%2F
%2Fprofile.typepad.com%2F&via=blogside&service=twitter&post_uri=http:
//adndevblog.typepad.com/autocad/2016/01/custom-python-scripts-for-autocad-
plant-3d-part-5.html) Google+ (http://www.typepad.com/sitelogin?uri=http
%3A%2F%2Fadndevblog.typepad.com%2Fautocad%2F2016%2F01%2Fcustom-
python-scripts-for-autocad-plant-3d-part-5.html&
fp=2416f6fe6e795b8413af6d64dbbf7e17&view_uri=http%3A%2F
%2Fprofile.typepad.com%2F&via=blogside&service=gplus&post_uri=http:
//adndevblog.typepad.com/autocad/2016/01/custom-python-scripts-for-autocad-
plant-3d-part-5.html) and more... (http://www.typepad.com/sitelogin?uri=http
%3A%2F%2Fadndevblog.typepad.com%2Fautocad%2F2016%2F01%2Fcustom-
python-scripts-for-autocad-plant-3d-part-5.html&
fp=2416f6fe6e795b8413af6d64dbbf7e17&view_uri=http%3A%2F
%2Fprofile.typepad.com%2F&via=blogside&service=openid&post_uri=http:
//adndevblog.typepad.com/autocad/2016/01/custom-python-scripts-for-autocad-
plant-3d-part-5.html)
8 of 9 4/03/2017 12:49 AM
Custom Python Scripts for AutoCAD Plant 3D Part 5 - AutoCAD... http://adndevblog.typepad.com/autocad/2016/01/custom-python...
(You can use HTML tags like <b> <i> and <ul> to style your text. URLs automatically linked.)
(http://www.typepad.com/)
9 of 9 4/03/2017 12:49 AM