KEMBAR78
Custom Python Scripts For AutoCAD Plant 3D | PDF | Integrated Development Environment | Computing
0% found this document useful (0 votes)
346 views6 pages

Custom Python Scripts For AutoCAD Plant 3D

This blog post introduces the development of custom Python scripts for AutoCAD Plant 3D, outlining the development process, necessary programs, and types of scripts. It emphasizes the lack of an integrated IDE for testing and debugging, and provides guidance on script storage locations. Future articles will delve deeper into custom script components and equipment packages.

Uploaded by

vinicius.packk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
346 views6 pages

Custom Python Scripts For AutoCAD Plant 3D

This blog post introduces the development of custom Python scripts for AutoCAD Plant 3D, outlining the development process, necessary programs, and types of scripts. It emphasizes the lack of an integrated IDE for testing and debugging, and provides guidance on script storage locations. Future articles will delve deeper into custom script components and equipment packages.

Uploaded by

vinicius.packk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

AutoCAD DevBlog (https://adndevblog.typepad.

com/autocad/)

06/10/2015
Custom Python Scripts for AutoCAD Plant 3D – Part 1
By David Wolfe (http://www.autodesk.com/expert-elite/featured-members/david-wolfe) (Contributor)

In this series of posts, we will cover developing custom python scripts for AutoCAD Plant 3D.

Along with learning about the development environment, we will cover troubleshooting, template scripts,
and deployment. The original AU course covering scripts and Plant 3D is available here
(http://www.pdoteam.com/download/custom-python-scripts-au-1/).

This blog article is going to assume some familiarity with Python. There are a lot of great resources for
learning python on the internet. To get started learning the language syntax I suggest using Code Academy
(http://www.codecademy.com/en/tracks/python).
This introductory article will start off by covering the basics of:
Description of the development process
Programs are necessary for development
Description of script types

Development Process
Unlike typical development done with .Net languages or even normal Python scripts, there is no integrated
IDE for compiling, testing, and debugging. The compiling is done by running a special command in Plant
3D, and then the scripts are loaded into memory for the AutoCAD session. Since the only way to test changes
is to start a new AutoCAD session, the process of troubleshooting
The steps in the development process are:

Define function(s) for modeling the custom part


Define the metadata header
Test the script
Create the snapshots
Build a script package (if necessary)
Deploy the content

Through the rest of the articles, we’ll break down these steps even further so that you have an accurate
understanding of the entire process. Along the way we will also develop a few custom scripts to help get you
started.

Development Programs

Due to the prevalence of Python, there are many good free editors. Since we are not looking for an IDE
(Integrated Development Environment), any of the text editors that highlight the Python syntax will work
well. I’ve used Komodo Edit (http://komodoide.com/komodo-edit/ ), but my preference for text editors is
TotalEdit Pro (http://www.codertools.com/default.aspx) (now free). Again, the main job here is just to color
the text. All of the testing of the code will be done in AutoCAD Plant, and there is no debugger to step
through.

When building scripts for Equipment, you will need to have a zip program. My personal favorite is 7-zip
(http://7-zip.org/), as it integrates well with the Windows Explorer right-click menu.

With xml files, you can use Foxe (http://www.firstobject.com/dn_editor.htm) which offers a customizable
tree view of the xml beside the xml content with syntax highlighting. Here’s a quick article
(http://www.pdoteam.com/2012/08/editing-xml-files/) showing how to customize the tree.

Script Types
Plant 3D uses scripts in a couple different ways, for equipment and also for catalog content. The scripts get
stored in special folders inside the shared content folder. The two special folders for scripts are:

C:\AutoCAD Plant 3D 20XX Content\CPak Common\equipment


C:\AutoCAD Plant 3D 20XX Content\CPak Common\CustomScripts

(https://adndevblog.typepad.com/.a/6a0167607c2431970b01b8d125afef970c-pi)

The paths are above are the default locations. If you are using a shared network location, these folder should
be located there. You may have to create the CustomScripts folder as it is not present by default.

If you are going to create an object that will connect to piping, and show as an end connection on the
isometric (and is not a nozzle), you should create an equipment script. Any other type of script will be
created as a custom script.

Equipment Scripts

These basic shapes (primitives) are hard coded into the program, and you cannot add your own routines to
this list.
(https://adndevblog.typepad.com/.a/6a0167607c2431970b01b8d125affa970c-pi)
Another type of script is for generating a complete equipment item. For example, the Centrifugal Pump script
generates the entire pump, and the user inputs values for the parameters.

(https://adndevblog.typepad.com/.a/6a0167607c2431970b01bb084074ba970d-pi)

Scripts of this type generate the entire equipment item without removable parts.

Synopsis
In this article you learned some high-level information about developing Python scripts for Plant 3D. You
learned which program will be used to modify equipment packages and script files, as well as the key
locations for developing and testing those files. The next article will describe the parts of a custom script and
the custom equipment packages in more detail.
Posted at 12:14 PM in Plant3D (https://adndevblog.typepad.com/autocad/plant3d/) | Permalink
(https://adndevblog.typepad.com/autocad/2015/06/custom-python-scripts-for-autocad-plant-3d-part-1.html)

Comments
Roberto Tsuri (http://www.compucad.com.mx/) said...

Hi David!
¿Can these still work for 2018 Plant version?
Thanks!

Reply
11/01/2017 at 11:04 AM (https://adndevblog.typepad.com/autocad/2015/06/custom-python-scripts-for-autocad-plant-3d-part-
1.html#comment-6a0167607c2431970b01b8d2ba16e7970c)
Comment below or sign in with Typepad (https://www.typepad.com/sitelogin?
uri=https%3A%2F%2Fadndevblog.typepad.com%2Fautocad%2F2015%2F06%2Fcustom-python-scripts-for-autocad-plant-3d-
part-
1.html&fp=f18f17eb1a2acd3143aeb086483c5c3e&view_uri=https%3A%2F%2Fprofile.typepad.com%2F&via=blogside&post_uri=https://adndevblog.typepad.com/autocad/2015/06/custom-
python-scripts-for-autocad-plant-3d-part-1.html) Facebook (https://www.typepad.com/sitelogin?
uri=https%3A%2F%2Fadndevblog.typepad.com%2Fautocad%2F2015%2F06%2Fcustom-python-scripts-for-autocad-plant-3d-
part-
1.html&fp=f18f17eb1a2acd3143aeb086483c5c3e&view_uri=https%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=facebook&post_uri=https://adndevblog.typepad.com/autocad/2015/06/cust
python-scripts-for-autocad-plant-3d-part-1.html) Twitter (https://www.typepad.com/sitelogin?
uri=https%3A%2F%2Fadndevblog.typepad.com%2Fautocad%2F2015%2F06%2Fcustom-python-scripts-for-autocad-plant-3d-
part-
1.html&fp=f18f17eb1a2acd3143aeb086483c5c3e&view_uri=https%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=twitter&post_uri=https://adndevblog.typepad.com/autocad/2015/06/custom
python-scripts-for-autocad-plant-3d-part-1.html) and more... (https://www.typepad.com/sitelogin?
uri=https%3A%2F%2Fadndevblog.typepad.com%2Fautocad%2F2015%2F06%2Fcustom-python-scripts-for-autocad-plant-3d-
part-
1.html&fp=f18f17eb1a2acd3143aeb086483c5c3e&view_uri=https%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=openid&post_uri=https://adndevblog.typepad.com/autocad/2015/06/custom
python-scripts-for-autocad-plant-3d-part-1.html)

(You can use HTML tags like <b> <i> and <ul> to style your text. URLs automatically linked.)

Email address is not displayed with comment.

Name

Email Address

Web Site URL

Post Preview

(https://www.typepad.com/)

AutoCAD DevBlog (https://adndevblog.typepad.com/autocad/)

Privacy settings | Do not sell or share my personal information (https://www.autodesk.com/company/legal-notices-trademarks/ccpa-do-not-sell)

You might also like