Skip to main content
1-Visitor
February 1, 2017
Solved

Script to add parameters/relations for every part in assembly

  • February 1, 2017
  • 5 replies
  • 13268 views

Hello,

Maybe someone know where I could find information about ways to solve problem like that? Any hints on where to start would be helpful, since I have close to no scripting experience with Creo.

In my work I make assemblies of various parts and later need to do drawings with BoM's, to do that I need to fill up table in parameters with part number, name and usage, I found its easier to copy that information in relations from spreadsheet that adds variable names which I'm doing at the moment, however, in bigger assemblies (20-40 parts, sometimes even bigger then that) doing that to every part takes tremendous amount of time, which decreases productivity by a lot.

To achieve a task, I have some things that might help.

  1. Every part's name starts with it's number, which is also copy'able into relations. For example part's name is (123456 XXXX-YYY-BB-CCC-D, then text that I need to copy into it (name is needed only to know where I need to copy relations into) would be something like

number='123456'
type_bom='XXXX-YYY-BB-CCC-D'
name_bom='Example name'

qtybom=''

     2. I get my data that I need to copy in excel spreadsheet where for example 2-6 column is always for first part, 7-11 for second and so on.

I have idea's how to take text from spreadsheet and use it to copy, but part where I need to script to choose file/actualy copy it gives me tons of problems, the best thing that I managed to reach was a mapkey that opens relations and after you copy your text into it it saves and closes part.

Any help would be helpful, thanks in advance.

Best answer by Jose_Costa

So.... from what I understood, keeping that spreadsheet file is crucial, there's no way you want to get rid of it.

What you want is a automated process to copy the content of some specific cells in a spreadsheet to some specific parameters in some specific parts.

This wouldn't be approach that I would take certainly, but with some work and patience I think it can be achieved.

There isn't that type of connection between Excel and Creo, if you follow this way, you will have to spend money or spend time, you choose .

If you choose to spend money, search for Nitro-Bom or SmartAssembly, they are third party addons, that maybe can do that.

Ask for a trial version and test. Remember that if you have more co-workers and they work the same way, you will need more licenses.

If you choose to spend time, search for Creo API's, you can build your customs apps for Creo using J-link, WebLink, VB, VBNet, Toolkit, all free except Toolkit.

I would recommend J-Link, is Java based and quite powerfull.

You can also take a look on scripting languages like Autohotkey or Autoit, they're based on simulations of keystrokes. If you build the spreadsheet with some logic, sending keystrokes between the Creo and the spreadsheet may be enough, but that depends how well organized is your spreadsheet.

Good luck.

Jose

5 replies

17-Peridot
February 4, 2017

We did something like this using Nitro-BOM and a plugin for it that can be used to update Model Relations across an Assembly Structure.

The model relations part is the toughest ... the parameters are easy across the Model Structure.

The other thing that I a "trick" is to use a BOM REPORT Table on your drawing using model filters for the parameters.  To be honest, this can work very well - but is often a pain to get working consistently - it requires a LOT of standardization of how you do parameters to get the BOM Tables to show up correctly - all edits must be done via parameters thereafter to make changes / updates.

Hope this helps in some way.

12-Amethyst
February 5, 2017

From what I understand, the values of the parameters will change from part to part.

Wouldn't be more easy if you add the parameters to the modeltree and fill them there?

Copy/paste there and little changes can be managed very fast.

aaaa.png

itrepkus1-VisitorAuthor
1-Visitor
February 6, 2017

This would take even more time, since now we can copy all 5 parameters into relations at once and they are never edited after that.

12-Amethyst
February 6, 2017

But are the same for all parts?

15-Moonstone
February 6, 2017

I think that what you are trying to do, Creo is really set up to do all this for you.

Have the parameters set up and set to their vaule in each part.   Set up repeat regions in your assembly drawings.  Add filters and relations to the repeat regions. 

Read up on repeat regions and relations therewithin.

Creo Parametric Help Center

itrepkus1-VisitorAuthor
1-Visitor
February 7, 2017

Thanks for your solution, but I don't have problems with drawings after I set up all parameters, time consumption of setting them is my main problem that I'm trying to solve.

12-Amethyst
February 7, 2017

I think I understand now and I agree with Mark, relations and repeat regions is all you need.

 

For the "number" and "type_bom", you can use relations to extract them from partname. Add them to your start parts and problem solved

number='123456'

type_bom='XXXX-YYY-BB-CCC-D'

 

Take a look at: Solved: Pulling the model name in as a parameter - PTC Community

 

For the other two,  create a drawing with repeat regions, quantity will be filled automatically, the name_bom since follows no rule you can fill it there manually.

 

Take a look at this video for example:

 

Hope it helps.

 

Jose

itrepkus1-VisitorAuthor
1-Visitor
February 7, 2017

I could take number automatically, but can't do that with type since there are some naming changes done due to windows file name'ing limitations. Repeat regions is set up and BoM is filled without problems when you set up relation.,

The problem that I'm having isn't how to do it, but more of "How to do it without using few minutes for every project", your idea with setting a parameter would work, but my ultimate goal is to remove any need for human input when writing data from text file and I hope the name to be used to find where to write which part of data from text file, rather then use the name itself.

15-Moonstone
February 7, 2017

I will 2nd what Jose is saying as well.  Use the Extract function in relations.  Keeping information in a separate text file seems to be holding you back.    Setting up automation in Creo is a lot like modeling in Creo.   You have to have your design intent planned out up front.   Yes for the existing product you have some rework to do, but going forward have these things set up in your base relations. 

12-Amethyst
February 8, 2017

So.... from what I understood, keeping that spreadsheet file is crucial, there's no way you want to get rid of it.

What you want is a automated process to copy the content of some specific cells in a spreadsheet to some specific parameters in some specific parts.

This wouldn't be approach that I would take certainly, but with some work and patience I think it can be achieved.

There isn't that type of connection between Excel and Creo, if you follow this way, you will have to spend money or spend time, you choose .

If you choose to spend money, search for Nitro-Bom or SmartAssembly, they are third party addons, that maybe can do that.

Ask for a trial version and test. Remember that if you have more co-workers and they work the same way, you will need more licenses.

If you choose to spend time, search for Creo API's, you can build your customs apps for Creo using J-link, WebLink, VB, VBNet, Toolkit, all free except Toolkit.

I would recommend J-Link, is Java based and quite powerfull.

You can also take a look on scripting languages like Autohotkey or Autoit, they're based on simulations of keystrokes. If you build the spreadsheet with some logic, sending keystrokes between the Creo and the spreadsheet may be enough, but that depends how well organized is your spreadsheet.

Good luck.

Jose

17-Peridot
February 8, 2017

Thanks for the Nitro-BOM plug!

Years ago - we did create a plug-in for Nitro-BOM for a customer to "cleanup" relations - but this assumed that you already knew what you wanted to change across the assembly structure.  We gave that away to any customer who needed it and owned Nitro-BOM already.  This is what it looked like:

Nitro-BOM-RelCleanupPlugin.png

The cool thing about this -- it "fixed" relations that were previously defined. However, it did not "add" relations to a model... that would be an easy thing to do in this plug-in.

Ideally, this would be better done in Nitro-CELL in my opinion for a simple reason.  We just added a stack of functions that allow a user to batch-export Model/Drawing Parameters and Notes to Excel - it is called a GET_APPEND function (gets data from CREO and appends it to an excel worksheet).  You can make changes in Excel and push them back to CREO via Nitro-CELL.  Here is a video overview of how that works:

GET_APPEND Overview - YouTube

It would not be that hard to add a new function to Nitro-CELL to do GET_APPEND calls for Model Relations.  It is an interesting idea - never thought of that until this discussion thread.  Not sure it is a heavy need for this type of manipulation.

Is this THAT big of an issue for everyone?

Dave