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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Scripting multiple part creation with changing colours?

xwalker
7-Bedrock

Scripting multiple part creation with changing colours?

I don't know if this is possible.

I'm creating a library of electronic resistors that are identified with colour bands.

There are potentially a few hundred to create which would be an incredibly laborious task.

Is there a way to assign a variable for each colour and then have some kind of automated / macro / script that will generate (create and save as a STEP file) a list of parts by providing a table of values for each of the variable colours?

Each resistor has between 3 and 5 colour bands (example below has 4).


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
ACCEPTED SOLUTION

Accepted Solutions
gkoch
12-Amethyst
(To:xwalker)

Hello Xavier,

The Pro/PROGRAM functionality should be a basic functionality which is always available (under Tools > Model Intent > Program), but it's not so often used.

It's like simple programming of parts, expanding relations by adding the option to prompt user input and suppress/resume features by conditional statements. So you can calculate parameters based on input and then modify or suppress features based on the calculation. Makes designs very flexible.

But since you probably need the parts only once to export them and then probably never again, I agree that it may be easiest to change the export files (if you know where you need to change them).

Anyway, FYI I attached a very simple example model (colors are applied to different offset surfaces):

Regenerate to get the GET INPUT menu, select Enter to change design, checkmark parameters to change (there is only one for simplicity) and enter color following the prompt

Regards,

Gunter

View solution in original post

8 REPLIES 8

Hi,

see my reply at VRML parts not rendered when exported to Keyshot

MH


Martin Hanák

Thanks Martin, that's an interesting thought.

After initially struggling to get the colours in the STEP Exports (Creo doesn't default to the AP214 format, you have to define it in the preferences), it looks like this could be the easiest way...

TomU
23-Emerald IV
(To:xwalker)

Do you need them to be STEP files, or would you prefer to keep them native Creo files?

It seems like it would be pretty easy to add multiple color surfaces to the model and then turn them on and off with either Pro/PROGRAM and relations or a family table.

xwalker
7-Bedrock
(To:TomU)

I'd need STEP files - the external program I'm using for 3D visualisation requires STEP models.

The alternative is to try and do something with FreeCAD and CadQuery where you can write parametric python scripts to generate various geometric shapes. It's what's been used to do a long list of surface mount electronic components. But the libraries don't include vertically mounted through-hole resistors which is what I need.

I could try and get my head around creating python scripts, but as I use Creo for my enclosure designs and other 3D modelling, I though I could do them here.

But it sounds like it's a relatively complex process and if I'm going to have to learn another part of Creo which I don't know yet, it might be easier for me to do it directly with CadQuery / python scripting.

gkoch
12-Amethyst
(To:xwalker)

  • You can add color to the default STEP export (AP203) by config.pro option step_appearance_layers_groups yes
  • The idea from Tom using Pro/PROGRAM or family table functionality with a couple of relations seems a good idea to me, especialy if the shape never changes and it's only about colors. For each ring you will need one offset surface feature for each possible color and then design the program to show them depending on input parameters.
  • Another alternative maybe would be using trail files. Open the model and explicitly apply a color to each of the surfaces, then export it under the desired STEP name. Create copies of the trail file and in the copies change the colors and the export name, then run them.
    The lines to change in the trail file should look like this one:
    ~ Select `main_dlg_cur` `ProCmdViewGallery_layoutph.palette_holder.myAppPalette.NamesList` 1 `ptc-metallic-blue`
    I believe changing the color name should make the desired change, but I recommend to first do a short test with only one or two surfaces, in case I am wrong.
    If you are a programmer, then for several hundreds of parts, it may even be worth the time to create a short program to generate the different trail files.
    Or if you add the closing of the model window to the recorded actions, you may even be able to merge all trail files into a large one and run it over night, exporting all parts.

xwalker
7-Bedrock
(To:gkoch)

Thanks Gunter. In the end, I changed the STEP export format to AP214, so I have all the colour information in the files.

Right now, I've found out it's easier to manually edit the STEP files, changing the colour information in there. That's probably simpler than using trial files - but thanks for your suggestion

I'll have to ask my colleagues, but I don't think I have the Pro/PROGRAM feature in my install, so it may be all academic.

In the long run, if we want several hundreds of parts, I'll figure out how to do it with some python scripts as the whole cadquery toolset should be capable of doing it.

gkoch
12-Amethyst
(To:xwalker)

Hello Xavier,

The Pro/PROGRAM functionality should be a basic functionality which is always available (under Tools > Model Intent > Program), but it's not so often used.

It's like simple programming of parts, expanding relations by adding the option to prompt user input and suppress/resume features by conditional statements. So you can calculate parameters based on input and then modify or suppress features based on the calculation. Makes designs very flexible.

But since you probably need the parts only once to export them and then probably never again, I agree that it may be easiest to change the export files (if you know where you need to change them).

Anyway, FYI I attached a very simple example model (colors are applied to different offset surfaces):

Regenerate to get the GET INPUT menu, select Enter to change design, checkmark parameters to change (there is only one for simplicity) and enter color following the prompt

Regards,

Gunter

xwalker
7-Bedrock
(To:gkoch)

Ah great, I'll look at understanding how that works, but from your cube example, it wouldn't take me that long to rattle through the 20 or so important colour sets I need right now.

That's great. Thanks

edit: is it possible to take this one step further and somehow script / macro it so that the "questions" it asks (which of course you requested in the programming) can be answered by a parameters file or table? If it's possible to do that and then save the component using a filename in the parameters file / table, then you could automate the process.

edit2: learning to walk before attempting to run looking at the program, I can see that chosing a colour calls up a different feature ID: red = internal feature ID 82, green = 105, etc.

I can't see where we assign the colour to the internal feature ID. Could you please point me in the right direction? I'll then be able to adapt to my resistor model.

Thanks again!

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags