cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Script to add parameters/relations for every part in assembly

itrepkus
2-Explorer

Script to add parameters/relations for every part in assembly

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.

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

16 REPLIES 16

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.

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

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.

But are the same for all parts?

No, two parts never have a single same parameter. Basically I download part from some companies catalog and need to add certain data about those parts (like number and type). Thats why it never changes, but I need to add that info for every single pat in assembly.

psobejko
13-Aquamarine
(To:itrepkus)

I am not sure, but it sounds like that you are trying to automate copying-and pasting of information from multiple cells in an excel worksheet into the parameters of a Creo model.

The nitro-cell solution sounds like it would work best for you.

One thing I'd like to suggest if you get your data from the vendor in non Pro-E format, for example STEP.  You should set up an import recipe that directs Creo to use a template part and template assembly when converting the data.  You set up these templates based on company-standards, and so they would have the "number",

"name_bom", ... parameters defined.

Look for "import profile editor" using the search in the upper right corner, and the config.pro options intf_profile_dir and intf_in_profile_default

In this way, the imported parts already have the parameters defined, and so you can set up your model tree to display columns of these parameters and essentially have an empty spreadsheet in creo that you fill out from the information in Excel.

(or you create your drawing of the assembly and insert the BOM table and fill it out).

It's still a lot of clicking around, but at least you are only dealing with two side-by-side windows...

msteffke
14-Alexandrite
(To:itrepkus)

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

itrepkus
2-Explorer
(To:msteffke)

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.

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

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.

msteffke
14-Alexandrite
(To:itrepkus)

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. 

itrepkus
2-Explorer
(To:msteffke)

I don't understand what you wrote about automation, because I even wrote that I'm trying to remove users input.

Adding parameters that I then have to write in only changes problem, while solving anything at all. I will still have to copy text from my spreadsheet, but then I will have to do it even more times, because now I have to copy just once for every part.

Removing that single copy-paste operation per part is what I'm trying to achieve.

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

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

Well It's not crucial to keep it some other way, like copying that data to text file would save time, however I don't think any of the suggestions helped with that or I didn't understood something. API's solution was kind of what I was looking for, so it will have to do I guess since I can do exactly that, take data from text/csv file and hopefully it will let me write data in a way I want it.

Thanks for help everyone

This entire thread made us think a little bit more about the need for GET_APPEND functionality specific Model Relations in Nitro-CELL for some of our own customer automation projects.

The main thought was:

  • "export" relations to Excel (one relation line per cell in excel)
  • "edit" them (manually or by Excel Formula), and then
  • "import" them back. 

This seemed simple enough and useful in few situations we have experienced ourselves...  especially if you wanted to add relations to every model (part or assembly), or find and replace relations (editing them) in batch.

After a bit of internal discussion, we came up with a new GET_APPEND_RELS Model function for Nitro-CELL Execution Worksheets in Excel.  We also added a WRITE_FORMULAS Worksheet as a helper function that could be used in combination with GET_APPEND_RELS to use Excel Formulas to identify relation content and exclude it from re-import... Conceptually a neat thing.

Anyway.... Here is an example of how it works with a single model -- it can obviously be batched over multiple models via Nitro-CELL Batch Execution.

Nitro-CELL Functions - GetAppendRels Model - YouTube

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags