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

How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file? Pro Program? Something else?

Highlighted
Alexandrite

How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file? Pro Program? Something else?

We have a parameter/attribute driven .prt template that we want to use to create new models based off a text file. 

I looked at Pro/Program to do this but couldn’t find a Parameter/Attribute section.  I don’t think it would be a problem if the above were buried in the Pro-Program text file and it just replace the entire file, but I cannot even find which section this would go in.


E.g.  To use a simple example, let’s say we have a cylinder with 2 parameters, which drive the dimensions:
1) Diameter “Dia1”
2) Length “L1”

We then have relations that drive these 2 parameters that look something like this:
1) d1=dia1
2) d2=L1

We would like to have a text file that contains actual dimensions for “dia1” and “L1” to be able to create a model based off the above template and the contents of the text file such as:
Dia1=0.25”
L1=2.00”

Can Pro/Program be used for this?  Is there another way?  Is there a better way?  How can this be done?

19 REPLIES 19

Re: How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file?  Pro Program?  Something else?

I've only ever done this using trail files or mapkeys to modify existing part. I usually use VBA/Excel to generate the files. Pro/Program doesn't do this though some sort of Excel analysis might.

What is the workflow you expect to use if you had an ideal situation?

Highlighted

Re: How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file?  Pro Program?  Something else?

Expected use is:

User exports a text file containing driving parameters generated from a 3rd party program.

Mapkey to create the part from a template after the user references that part file with the driving parameters.

So the part of interest is a spring and we want to create the model based off of the spring design software output.

Highlighted

Re: How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file? Pro Program? Something else?

Hi,

yes, you can use Pro/PROGRAM.

Pro/PROGRAM example:

VERSION 2.0

REVNUM 86

LISTING FOR PART PRT0001

INPUT

VYSKA NUMBER

END INPUT

RELATIONS

D3=VYSKA

END RELATIONS

... and so on ...

When you regenerate a part, you use Read File command and enter file name (unfortunatelly you cannot browse folders...).

Example of myfile.txt contents

VYSKA=123


MH


Martin Hanák
Highlighted

Re: How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file? Pro Program? Something else?

We use Automation Gateway as well to handle parameters in models. It is easy to use, but it is not for free.

Highlighted

Re: How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file? Pro Program? Something else?

Hi Lawrence,

Your focus is "We have a parameter / attribute driven .prt template that we want to use to create new models based off a text file."

There are many ways to enter part parameter values and drive the part, but a simple way is from the relation.

Your idea is to go from a text file => Pro/Program => Part (* .prt), maybe change the workflow process to a text file =>Relation=> Part (* .prt).

Show an example as below,hope it helps you.

My English is pretty limited, please don't mind.

KC

pro_1.jpg

pro_2.jpg

pro_3.jpg

Highlighted

Re: How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file? Pro Program? Something else?

Hi  Gold ,

I think I can help you on this because that's the thing I am currently doing for my company.

Use Excel VBA and Mapkey in Creo, see example below:

Sub writeParameters()

Dim filePath, filePath1 As String, textData As String, fileNo As Integer

Dim FromPath, ToPath As String

Dim dataP01, dataP02, dataP03, dataP04, dsgDate, Ldate As String

Dim FSO As Object

Dim wbCnfgr As Workbook

      filePath = "full path and name of the text file which you write parameters to"   (Eg, "C:\AutoDesign\AutoDsg_D\A999-2740\03 CADFiles\15-X\xxx.txt")

     dataP01 = Range("A1")+ "=" +Range("B1")      '(A1=parameter name ,   B1= parameter value on your worksheet)

     dataP02 = Range("A2")+ "=" +Range("B2")

     dataP03 = Range("A3")+ "=" +Range("B3")

     dataP04 = Range("A4")+ "=" +Range("B4")

  Ldate = Date

  dsgDate = "/*Designed by ...on " + Ldate

fileNo = FreeFile 'Get first free file number

Open filePath For Append As #fileNo

Print #fileNo, dsgDate

Print #fileNo, dataP01

Print #fileNo, dataP02

Print #fileNo, dataP03

Print #fileNo, dataP04

Close #fileNo

'End If

End Sub

And in Creo you just create a makey to import the text file to your relation.

Highlighted

Re: How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file? Pro Program? Something else?

Two thoughts.  First, we have done something similar in the past to what KC Ai‌ is suggesting.  We created a bunch of feature parameters inside a stable (but never looked) in feature (one of the datum planes at the top of the model tree.)  We then created a mapkey to automatically browse to a folder and wait for us to pick a file, and then copy the contents of the file into this feature as feature relations.  Relations were added to the other features in the model so they referenced these feature parameters.  It was easy enough to build an Excel file that could directly generate the exact relations statements needed (we would copy them to a text file before importing.)

A second idea might be to use Nitro-CELL.  There is a free version available.  Definitely worth taking a look at.

Highlighted

Re: How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file? Pro Program? Something else?

Here's the method we have been using for the past 10 years:

Microsoft Excel drives our 3D models. Basicly its a combination of the solutions by Martin Hanak (CREO side) and Changxing Lin (EXCEL side)

EXCEL

1) Create an Excel spreadsheet to calculate the values of the parameters which drive your part/assembly. Make the Excel spreadsheet as fancy as you like.

2) Use one sheet of that Excel spreadsheet to hold all the parameters (name of parameter in column A, value in column B)

3) Create an (ActiveX) button and write a small Excel VBA macro which will export all the parameters and their values to a text-file.

We use the exact same text-file over and over again, overwriting the contents when we generate something new. For example: "c:\temp\my_creo_parameters.txt"

CREO

1) Use INPUT parameters

Each PART and ASSEMBLY are driven by INPUT parameters. You can use STRING, YES_NO and NUMBER.

2) Use EXECUTE statements

Use the EXECUTE statement in your assembly to drive the INPUT parameters of any PART and/or sub ASSEMBLY

3) Use Mapkeys

As soon as a part or assembly contains INPUT parameters, you will get the option to use "Read file" when regenerating that part/assembly. Create a mapkey that will do "Edit" --> "Regenerate"--> "Read File" --> "c:\temp\my_creo_parameters.txt". You can also assign a mapkey to a button.

FINAL WORKFLOW

1) Open the Excel spreadsheet, configure your design, hit the button in Excel to generate the "my_creo_parameters.txt"

2) Open your design (part/assemby) in CREO, hit the button which executes the mapkey to read the values from "my_creo_parameters.txt"

P.s. If you are wondering how many parameters you can use...our biggest model uses 1264 input parameters at top-level.

HTH

Highlighted

Re: How do you drive a Creo Parametric Part (.prt) parameters/attributes from file using a text file? Pro Program? Something else?

See attachment for an example.

Announcements
Message from Brian Thompson (PTC General Manager and DVP) regarding Creo Business Continuity plans.