Automating certain settings for AutoCAD Plant 3D environment

Automating certain settings for AutoCAD Plant 3D environment

theshoaib.mughal
Advocate Advocate
1,274 Views
6 Replies
Message 1 of 7

Automating certain settings for AutoCAD Plant 3D environment

theshoaib.mughal
Advocate
Advocate

Greetings,

 

I am new to AutoCAD scripting (.lsp or .scr) so I am here asking for help. Every time I create a project, I need to perform a certain number of settings of parameters which is quite a cumbersome job. If there is a way to automate this using a script (either LISP or SRC) that would be great.

 

Here is what I need to do;

Task 1: Creating PLANTENDCODES

  • I need to create an end code (Name="ABC", Description="ABC", checkbox=Can CutBack is checked)
  • Before creating the script must check if ABC is already there or not (to avoid multiple attempts on the same thing)

Task 2: Creating Piping Joints

  • In Project Setup \ Plant 3D DWG Settings \ Piping Connection Setting, there are Piping Joints. I need to create a new piping joint
  • Name & Description="JointABC"
  • End1 & End2 = "ABC" (the same as the created endcode above, if it's not there then endcode creation shall execute)
  • Adding a property named Nominal Diameter
  • Clicking the checkbox 'Universal' in the Fasteners section.

 

Can someone help me guide how to do these tasks (preferably without showing the dialog boxes of ENDCODES and PIPING CONNECTIONS i.e. silent settings)?

 

Thanks

0 Likes
1,275 Views
6 Replies
Replies (6)
Message 2 of 7

Michiel.Valcke
Advisor
Advisor

Both cannot be done with lisp or script.

 

The plantendcodes are saved in an xml file, modify or replace the file with the user and you'll have all the end codes you need. You only need the modified xml to modify the joint setup or to create new custom components. If your users don't need to do either, they don't need the xml.

https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/What-file-are-the-...

 

Techically you can read and write to an xml file with lisp, but it seems overkill.

 

The joint setup you might be able to modify with .net, but i'm not sure about that. You could also do the joint setup in a template project and use COMPAREPROJECT to copy them to your project.

0 Likes
Message 3 of 7

h_eger
Mentor
Mentor

Dear @theshoaib.mughal ,

 

I use the Plant Express Tools from Auxalia for such tasks.

-

If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).

Hartmut Eger
Senior Engineer
Anlagenplanung + Elektotechnik
XING | LinkedIn

EESignature



0 Likes
Message 4 of 7

theshoaib.mughal
Advocate
Advocate

Thanks, Michiel for your feedback. This is one option to consider. I will keep it in mind but it has one problem, I can update and share the XML file with the user but unless I can somehow append the already existing XML file on the user's machine, this solution doesn't work for me. Because I don't know what other changes and settings the user has made which are stored in their XML file. And if I replace it with mine then sure the endcodes and joints will be available but any other setting (if any) will be wiped.

 

But I will keep this in mind and try to figure out a way to append to already existing XML

 

Thanks

0 Likes
Message 5 of 7

theshoaib.mughal
Advocate
Advocate

Thanks h_eger,

 

I will certainly look into it to see if it works for me. Anyhow this is one example that I mentioned, learning to create a custom script for such a task will help me with other prospective options as well. If you have any reference on how I can learn this please do share it with me.

0 Likes
Message 6 of 7

Tomislav.Golubovic
Advisor
Advisor

What about copying a XML from the network to each persons machine as they start Plant3D, and then with the End Connection settings, just do it in your master project once, and then use that as a template for future projects. Also with current projects you just need to edit it once and its done.

0 Likes
Message 7 of 7

Michiel.Valcke
Advisor
Advisor

If you want to read/modify an .xml file through lisp it is possible. But the only reason why a user would need the modified PLANTENDCODE.xml would be if they create their own components with that endcode or if they need to create/modify joints with that code. 

To read/write an .xml file with lisp you would need the following steps:

(setq f (open "MyFileURL" "r")) ; "r" for read "a" for append "w" for write
(read-line f) ; read the first line from, and so one each time you repeat this statement, if the document is finished, this will return nil

(setq f (open "MyFileURL" "a")) ; append adds at the end of the document - write overwrites all document content - both create a new document if nonexistent
(write-line "MyString" f) ; add the line
(close f) ; the line only gets saved to the document when you use the close command.

(note: there's also a (read/write-char) command in lisp - see the glossary)

Lee Mac has some very clean read CSV and write CSV routines to write csv content to lists of strings and vice versa on his website. You can use those as a template to write to xml.

0 Likes