Multiple Materials On 1 Part - With Scripting

Started by nicktrick92, June 07, 2016, 03:22:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nicktrick92

Hey there, so I have another question regarding KeyShot scripting. My company uses CREO/PRO-E for our CAD files. What we need to do is take a CAD file that is pretty much one piece (Sometimes more), and put materials on different parts of that piece. For example, I have a gear that is one part, but I need to put a different material on the teeth, the face, and the bearing. And here's the catch, I have to do it with scripting... We need to do this to 15000 gears. How would I even begin to do this? I was thinking maybe a different mapping scheme, but how would you guys suggest I go on with this?

I am really confused about it, and I need to get this project done ASAP!

Thanks for the help,

-Nick

EDIT: I know how to do this manually, but now I just need to do this with scripts... For example, if I choose the parts on a model one that are supposed to be separated, it separates those parts on all 15000.

TpwUK

Have the modeller(s) assign different material names to the parts, then use root.find as you did before - As long as you know which materials go to what faces/parts it's relatively easy.

Martin

LayC42

That task is not that difficult.
Everything starts with the model. You need to assign specific colors to the faces of the parts (not as a color of a component)
Then you need to blank all unneeded quilts.
And  a material template in KeyShot that is standardized to the creo color code can map the materials.

Last step is the script with simple steps.
Read creo file and import it with this material template
Orient to ...
Use background ...
Render image to ...
Done!

nicktrick92

Quote from: LayC42 on June 07, 2016, 10:22:36 PM
That task is not that difficult.
Everything starts with the model. You need to assign specific colors to the faces of the parts (not as a color of a component)
Then you need to blank all unneeded quilts.
And  a material template in KeyShot that is standardized to the creo color code can map the materials.

Last step is the script with simple steps.
Read creo file and import it with this material template
Orient to ...
Use background ...
Render image to ...
Done!

So you're saying to basically map out one of the gears (In CREO (One for each different type of gear)) and then use that mapped gear to create a template for the others of the same kind and then apply that template to the others?

mertmg

Hi,
We're using Creo as well. I totally understand your trouble. I think best possible way is to give colours to sections. I'm not sure how you modelled the gears. But if you're using family tables you can find a way to put colours on them.
I've mapped +30 material in a scene easily with using color mapping. It is quite easy actually.

If you need help on Creo side let me know.

Cheers
Mert

Quote from: nicktrick92 on June 09, 2016, 09:17:07 AM
Quote from: LayC42 on June 07, 2016, 10:22:36 PM
That task is not that difficult.
Everything starts with the model. You need to assign specific colors to the faces of the parts (not as a color of a component)
Then you need to blank all unneeded quilts.
And  a material template in KeyShot that is standardized to the creo color code can map the materials.

Last step is the script with simple steps.
Read creo file and import it with this material template
Orient to ...
Use background ...
Render image to ...
Done!

So you're saying to basically map out one of the gears (In CREO (One for each different type of gear)) and then use that mapped gear to create a template for the others of the same kind and then apply that template to the others?

LayC42

Quote from: mertmg on June 10, 2016, 11:18:55 AM
...
But if you're using family tables you can find a way to put colours on them.
...

You can copy the material in creo (pro_material_dir) and bring in different colors.
Just attache the colors of the global.dmt to the material (preferences > appearance tab) and define the first one active (e.g. steel (density 7.81e+6) with a blue, red and green color). Then copy the default steel (.mtl) as steel_blue, steel_red, steel_green. Assign all three materials to the generic and don't forget to deselect the material of the generic (a generic with multiple materials has no mat assigned)
then you can define each material to another instance

Otherwise you can work with separate and colored copy surfs - but I don't like that solution

OK - I know that this is no CAD forum - so I apologize for this quick tip


gimme a PM if you need further descriptions.


hope that helps

nicktrick92

Okay guys, here's an update!

So basically, I found out that the gears come into KeyShot a bit differently than they came out of CREO. It puts together parts that shouldn't be together. The unfortunate part is that the part names include the model number, so I can't have it be a static name like "Teeth" or "Face". That brings up my next question... Is there a sort of UV map in KeyShot... Back in my animation days of Maya and Cinema 4D, we would make a model (A person for example) and use a UV map to basically put 2D textures on to a 3D model. Is there a way to make a UV Map for materials in KeyShot? Whatever we go with, it should all be done with scripting (We're not going to actually want to put materials on 15000 parts and render 4 views per part!

Last note: This should all be done with scripting... We already have the 15000 models made and we're not going back to edit them. We use a CREO family table, so that's where we will get the proper materials from, but the only thing the user should have to do is either make the material template or make a material map (if that exists). If possible, I could do some CREO scripting as well!

Thanks for all the help guys,

-Nick

guest84672

Can you explain the part about "it puts parts together that shouldn't be together"? I'm not sure I understand what you mean by that.

nicktrick92

Basically, in CREO, The face, the teeth, and the body of the gear are all seperated. For some reason, KeyShot separates the face from the body like it is in CREO, but combines the teeth and the body to form one part that must have the same material (Unless I edit geometry in KeyShot, but I can't do that in scripting).