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

Family table parameters in drawing

Highlighted
Alexandrite

Family table parameters in drawing

Hi,

 

I have created a family-table that has some instances. Then I created a drawing of the generic and replaced it with one of the instances of the family-table. In this drawing I want to display the name of the current instance. I want to create a simple (no repeatregion) table that shows the instance name and the common name of the current instance:

 

I tried the following:

 

FamilyTableInstanceName:         |         &fam.inst.name

 

I also tried &fam.inst.param.value and &fam.inst.param.name

 

Creo recognizes the parameter as parameter, but no instance-name is displayed. I also tried to switch symbols, but it doesn't show any value.

 

&fam.inst.param.value is automatically replaced with &fam.inst.param.value:1 and when I switch symbols it shows: fam.inst.param.value, but not the name of the instance.

 

Displaying other parameters of the assembly like &length:1 works.

 

So how can I show the current name of the instance (instance name and common name) in a drawing ?

 

Thanks,

Maik

 

 

 

19 REPLIES 19
Highlighted

Re: Family table parameters in drawing

Hi,

if you create drawing of family table instance (part), then you can use:

  • &model_name to show instance name
  • &PTC_COMMON_NAME to show instance common name
  • &paramname to show instanace parameter value

 


Martin Hanák
Highlighted

Re: Family table parameters in drawing

Thanks Martin. It works perfectly.

 

Now I'd like to save every drawing as *.pdf-File.

To do so I tried to created a mapkey. In this mapkey I go to File -> Save as -> PDF

The Filename in this Dialog-Box per default is the name of the drawing. But I want it to be the Instance-Name(&model_name + ".pdf"). It there a possibility to input the Instance-Name automatically ? Maybe it possible to insert a parameter in the Mapkey-code ? So I don't have to stop the Mapkey and insert it manually every time I execute the mapkey.

 

My plan is to somehow automatically open every instance (>50 instances) and execute the mapkey that replaces the drawing-model and saves it as .pdf-File. Is Creoson the easiest option to do that or are there other ways as well ?

 

Thanks

Highlighted

Re: Family table parameters in drawing


@MaikTheBike wrote:

Thanks Martin. It works perfectly.

 

Now I'd like to save every drawing as *.pdf-File.

To do so I tried to created a mapkey. In this mapkey I go to File -> Save as -> PDF

The Filename in this Dialog-Box per default is the name of the drawing. But I want it to be the Instance-Name(&model_name + ".pdf"). It there a possibility to input the Instance-Name automatically ? Maybe it possible to insert a parameter in the Mapkey-code ? So I don't have to stop the Mapkey and insert it manually every time I execute the mapkey.

 

My plan is to somehow automatically open every instance (>50 instances) and execute the mapkey that replaces the drawing-model and saves it as .pdf-File. Is Creoson the easiest option to do that or are there other ways as well ?

 

Thanks


Hi,

if I were you I would generate&play trail file. I can give you more information if you send me your trail file.

  1. launch Creo
  2. open drawing
  3. apply Date&time command
  4. replace drawing model
  5. save PDF (enter requested file name)
  6. exit Creo
  7. locate latest trail file and send it to me

Also open family table in Excel and copy instance name list into txt file and send it to me.

 

I will prepare BASIC program which takes trail filetxt file as input and generates new trail file for you. This BASIC program repeats block containing replace+save_PDF commands 50-times and puts requested name into every block. Then you simply play this new trail file.


Martin Hanák
Highlighted

Re: Family table parameters in drawing

Martin has some good suggestions.

 

If you wanted to do it with CREOSON... you can just use the "interface : export_pdf" function to perform the export (no mapkey required).  However, you may find that that you need to properly define your pen table and config.pro settings to get the export PDF to look like any settings you are setting in your mapkey via the standard dialog.  A bit of testing to get that right would be required - but once you have it ... it is done.  If you already have the pen table and config.pro configured - you can skip that prerequisite.

 

Basically, assuming you have your drawings already in your working directory for each instance name you are looking to generate your exports for.... you would do this "psudo code":

 

genericFile = model : open <genericFile>.prt

genericFileRootName = (get root name of genericFile - in javscript: genericFileRootName = genericFile.split(".")[0];)

instanceNames = file : list_instances

for each instName in instanceNames

// open the drawing

model : open file = <instName>+".drw" display = true

// export the pdf

interface : export_pdf  filename = <genericFileRootName>+"_"+<instName>+".pdf"

 

The process would continue until all of the instances in the generic were completed.

 

So you have many options to get there.   These little common processes are motivating some ideas on our end as they keep coming up. The question we struggle with is "how" to get some of these needs translated into something very approachable for people between "user" and "developer/scripting" types.  🙂

 

Dave

Highlighted

Re: Family table parameters in drawing

Thanks for your replies.

I think i will try both ways to lern them. 

Martin, does your batchfile create one big trail-file or one trail-file per PDF-file ? I will try to write a program in c++ that replaces the replace-instances and the PDF-filenames.

 

David, maybe you can write a html-file that contains the JavaScript code that opens and saves the instances as PDF when pressing a Button, if that isn't too much work? Im not very familiar with javascript and it would be very nice to have such an example that i can modify and play with...

 

thanks

Highlighted

Re: Family table parameters in drawing

I am always up for a little challenge to show off how COOL CREOSON is... 😉

 

Attached is a ZIP file that contains the HTML file that does what you are looking for in your example as a baseline - it also has a couple of test Creo files (Creo 4).

 

There are some comments in the HTML code to try to explain a few things.  It should be easy to follow - the main code is near the bottom of the HTML Source.

 

It does the following:

  • Assumes your current active model is the generic
  • checks for any instances in that active model
  • processes each instance into a PDF file in your working directory with a custom name (<generic>_<inst>.<ext>)

You just need to download the HTML file and put it in your CREOSON/web directory - then open it in your web browser.  (assuming you have CREOSON running)

 

The link after you put the file in the CREOSON/web directory should be : http://localhost:9056/batchInstToPdf.html

 

This code could be used as a baseline for doing other things quite easily.  You just have to be careful about following the workflow that it does currently and try to slip in other cool stuff you want to do - there is a bit of a pattern to coding these and putting it together. 

 

Just put the Creo files in a separate directory, make that your working directory and you should get a nice example after you load the testpart.prt into Creo's session (again they are Creo 4 files - but you can use Creo 5 or 6 no problem).  Here is what it looks like when finished:

 

2019-12-07 at 1.49 PM.png

 

Looking forward to your feedback and hope it encourages you to dig deeper into CREOSON!

 

Dave

 

Highlighted

Re: Family table parameters in drawing


@MaikTheBike wrote:

...

Martin, does your batchfile create one big trail-file or one trail-file per PDF-file ? I will try to write a program in c++ that replaces the replace-instances and the PDF-filenames.

...

 Hi,

I do not understand your question perfectly.

My BASIC program will produce the output I want. If I need one big trail-file it creates it. If I need one trail-file per PDF-file it creates them.


Martin Hanák
Highlighted

Re: Family table parameters in drawing

hi and thanks for your help

 

@MartinHanak 

 

I thought that it was possible to write a program that reads the trail.txt file, replaces the name of the instances and PDF-filename with the new/next instance and filename and then saves it. This would create one trail-file per saveToPdf-operation. But it doesn't seem to be possible to play more than one trailFile at once in Creo...

So the program has to create one big trail-file that includes all of the SaveToPDF-operations ? Is there already a tool availibe that creates this code or did you write the program yourself ?

 

@DavidBigelow 

I launched your program and it worked. It created one PDF-File per instance, but in the PDF-Files only contain screenshots of the different parts. Is it also possible to export a drawing of every instance of the familyTable ?

I have created one drawing for the generic part. It has to be replaced with every instance and then it should be saved as PDF. That would be awesome.

 

Thanks...

Highlighted

Re: Family table parameters in drawing

@MaikTheBike ... There are really two (2) [or more] ways to get to your desired solution using CREOSON.  It really depends on the quality you want in the end and your starting point.  Here are a couple of options to consider (included some sample files to play with on your end for each of these Solutions I am showing here - keep reading):

 

Solution 1:  Use a Drawing Template to Generate new Drawings for each Instance

  • Advantage - quick and easy
  • Disadvantage  - well ....  you have to create a drawing template - likely specific to your use case - and will likely not address all your dimensioning requirements and goals since they are basic starting points.  This may not be the best solution - but is a good exercise to consider for the future - typically when first generating drawings for a new design - not after they have been created (which is more the use case I think you are trying to address - see Solution 2).

Solution 2: Replace an already created generic drawing with Instance

  • Advantage - you get a drawing that is basically complete
  • Disadvantage - unless the drawing is really well done and constrained for dimension locations and note placements, etc. ---  manual review is likely to make sure all the dimensions, views and scaling is correct.  There are a few ways to accomplish this within Creo, some methods better than others. 

I opted to use a mapkey to execute the "Drawing Models" "Replace" function because it was the cleanest vs. the "Replace View Model" which requires user interaction for the view selection.  That was a technique decision on my behalf and I think it worked OK.

 

Pro-Tip : You can pro-actively fix the scaling on your drawings to automatically adjust to changes in size by simply pre-defining a DRAWING_SCALE_FACTOR relation in your generic model relations.  This should catch most of your scaling issue since the formula would be based on a target view size relative to the size of the instance you are displaying after it is replaced.

 

To better highlight the power of CREOSON, I have BOTH of the above scenarios in the attached zip file with some sample models.

 

Solution 1 : batchGenInstDrwsByTemplateAndPdfs.html (demo purposes only)

This requires a drawing template (mytemplate.drw) and your generic model (testpart.prt) as an inputs and will:

  • erase memory
  • open the generic model
  • get the list of instances from the model
  • then loop through each instance
    • create a drawing for each instance using a creo drawing template
    • save the new drawing
    • generate a PDF of the new drawing
  • then go to the next instance and do it all again

Note: The approach I used for Solution 1 is not as order of operation specific as Solution 2 ... Solution 2 is more structured and better approach in my view (mainly required because of the same starting drawing starting point) - but Solution 1 highlights a nice CREOSON capability for using drawing templates in a batch process to generate drawings and PDFs.  (which I am sure someone will ask about at some point)

 

Solution 2 : batchGenInstDrwsAndPdfs.html  (what you really want - I think)

This requires your generic drawing (generic.drw in my example) name to be input.

The process will:

  • erase memory
  • open the drawing
  • get the active model on the drawing
  • check for any instances
  • then loop through each instance
    • replace the active model with the instance in the drawing (mapkey used for this)
    • save the new drawing with a new name
    • generate a PDF of the Drawing
  • then go to the next instance and to it all again...

The instance drawings and PDFs will be stored in the Creo working directory. 😉

 

It is really important to make sure your view scales and detailing controls (snaplines) are properly setup for the best results within your generic drawing.  Every drawing will likely require some tweaks if you have not done this.  The changes in active models may result in things not scaling properly or dimension locations overlapping due to geometry/feature size changes (but that is always an issue it seems).

 

The source code is within each HTML file - so it could be modified and customized to your own purpose pretty easily.  The toughest part (for me) was JavaSrcript and its default asynchronous execution model - this requires some taming to make work the way you want... mainly because you have to understand what is going on in Creo for each operation to make sure you don't assume one state when Creo is in another within your script/program.   

 

For example (code talk): Loading things into memory and specifically targeting them is easy with any coding specific to Creo.  It is not until you have to run a mapkey that things get interesting (and sometimes that is all you can do - meaning there is no specific API for ALL operations in Creo are available).  To properly handle these scenarios requires each model/drawing to be active for the mapkey to run, and that requires a bit more thought about the order of operations to make it work properly - regardless of your code/approach - it is just something you have to think about to be successful when automating Creo.  Mapkeys do not return "when" they are done.. so this part can be tricky for long running processes being triggered by a mapkey.

 

To get these examples running - just copy them into your CREOSON/web directory as before, make sure CREOSON is started and you should be able to access each file by the following urls:

 

  • http://localhost:9056/batchGenInstDrwsByTemplateAndPdfs.html
  • http://localhost:9056/batchGenInstDrwsAndPdfs.html

 

Don't forget to put the example files into a working directory -- and change Creo to that location before you run either of the above web pages/scripts.  Once you get comfortable - you can change your Creo Working Directory to where your models are that you want to try the code with.

 

Anyway - sorry for the very detailed response... Give each solution a try - I think you can modify the code with additional CREOSON functions if you need without much headache - or restructure the existing code.  This is all in RAW JavaScript - so a package would be easier to use at some point (or use CREOPYSON for Python for a more streamlined coding experience).  Either way, it is all about the data and workflow in my view -- leveraging what PTC provides as you go.

 

Have fun!  I hope this encourages you to dig deeper into CREOSON... it is really powerful for most automation goals if you plan ahead.

 

Dave

Highlighted

Re: Family table parameters in drawing


@MaikTheBike wrote:

hi and thanks for your help

 

@MartinHanak 

 

I thought that it was possible to write a program that reads the trail.txt file, replaces the name of the instances and PDF-filename with the new/next instance and filename and then saves it. This would create one trail-file per saveToPdf-operation. But it doesn't seem to be possible to play more than one trailFile at once in Creo...

So the program has to create one big trail-file that includes all of the SaveToPDF-operations ? Is there already a tool availibe that creates this code or did you write the program yourself ?

 


Hi,

option no.1 ... create one big trail-file that includes all of the SaveToPDF-operations

option no.2 (I have never used this way) ... create one trail-file per saveToPdf-operation -AND- create one MAIN trail file which calls saveToPdf trail files one by one

 

Note: If I need to generate "batch" trail file, I write simple BASIC program by myself.

 

 


Martin Hanák
Highlighted

Re: Family table parameters in drawing

Hi @MaikTheBike 

unzip uploaded file and read _2019-12-10_INFO.doc document.

Note: I am not 100% sure whether mytrail.txt will work well, because I cannot test it.


Martin Hanák
Highlighted

Re: Family table parameters in drawing

Thanks for all of your help.

 

@DavidBigelow :

 That was exactly what I was looking for. It works really well and I think Creoson has a huge potential. I think one can create some cool projects with it. For example a website that creates complex 3d-Models or drawings on the fly that can be downloaded from the server...

 

@MartinHanak

Your Trail-file worked perfectly. It created the 50 Drawings very quickly.

 

Theres one more thing in the Project that I don't know how to solve...

The Project is an assembly with a Familytable that loads two components (Part1 and Part2). In some instances one of the parts is suppressed (in Familytable Component: N).

 

Is there a possibility to find out, if the part exists or not in the relations ?

I want to do something like:

 

If (part1 exists in this assembly)

   variable = xyz;

else

   variable = abc;

endif

 

Thanks,

Highlighted

Re: Family table parameters in drawing


Theres one more thing in the Project that I don't know how to solve...

The Project is an assembly with a Familytable that loads two components (Part1 and Part2). In some instances one of the parts is suppressed (in Familytable Component: N).

 

Is there a possibility to find out, if the part exists or not in the relations ?

I want to do something like:

 

If (part1 exists in this assembly)

   variable = xyz;

else

   variable = abc;

endif

 

Thanks,


Hi,

see https://support.ptc.com/help/creo/creo_pma/r6.0/usascii/#page/fundamentals%2Ffundamentals%2Ffund_sev... 

and uploaded assembly.

 


Martin Hanák
Highlighted

Re: Family table parameters in drawing

Hi,

 

@DavidBigelow:

I took a look at Creopyson and it seems to be even easier to use. Very nice...

 

@MartinHanak:

I tried the following code:

 

if exists("asm_mbr_partname")
a = 4*a*b

else
a = a*b*c
endif

 

But it doesn't really seem to work. The program always runs into the ELSE-Part of the code although the part exists in the instance. Maybe I'm doing something wrong ?

 

Thanks,

Highlighted

Re: Family table parameters in drawing


@MartinHanak:

I tried the following code:

 

if exists("asm_mbr_partname")
a = 4*a*b

else
a = a*b*c
endif

 

But it doesn't really seem to work. The program always runs into the ELSE-Part of the code although the part exists in the instance. Maybe I'm doing something wrong ?

 

Thanks,


Hi,

asm_mbr_partname notation can be used in repeat region relations (in Drawing mode), only.

It is impossible for me to guess what are you doing. If you want me to help you you have to upload your files (zipped in single zip-file).


Martin Hanák
Highlighted

Re: Family table parameters in drawing

Hi,

 

I try to explain what I want to do with a little fictitious example.

 

Lets say I've got an assembly called "house", which has a familyTable.

A component "carport" is added to the familyTable.

 

In some instances the carport exists and in some instances the carport doesn't exist ( Component YES / NO in familytable).

If the carport exists (in the instance) the height of the house (dimension d30) has to be twice the length of the house.

 

So I need something like:

 

if(component_carport_exists_in_this_instance)

d30 = length_Of_House * 2

endif

 

If I haven't described the example well enough I will upload an example.

 

Thanks for your help.

Highlighted

Re: Family table parameters in drawing


@MaikTheBike wrote:

Hi,

 

I try to explain what I want to do with a little fictitious example.

 

Lets say I've got an assembly called "house", which has a familyTable.

A component "carport" is added to the familyTable.

 

In some instances the carport exists and in some instances the carport doesn't exist ( Component YES / NO in familytable).

If the carport exists (in the instance) the height of the house (dimension d30) has to be twice the length of the house.

 

So I need something like:

 

if(component_carport_exists_in_this_instance)

d30 = length_Of_House * 2

endif

 

If I haven't described the example well enough I will upload an example.

 

Thanks for your help.


Hi,

please upload "test" assembly. I saves my time.


Martin Hanák
Highlighted

Re: Family table parameters in drawing

Is there any reason you could not set a parameter in the carport top level model that either controls, or represents, the state of the family table instance (and is also included as a column in the family table).... then use that in your house assembly to check for the state of your sub-assembly carport parameter state value?

 

Seem that would be a quick thing to do -- and would be consistent across all instances.  The downside - your top-level assembly would always assume that relation was valid... which may be a good thing or a bad depending on the greater view of your automation goals.

 

You could also look at a lookup_inst() in your top-level relations to be more dynamic - BUT I believe this only works for numeric matching values in your family table and has limited number of options. -- so you would have to likely add a column anyway to your family table to take care of that requirement.

 

To be way more generic, move some of this logic externally and check the state of things before making the final changes to dimensions/parameters.    For example via "psudo-code" in CREOSON:

 

// this assumes the toplevel assembly is active and the carport would only be insession if it was currently relevant

// check if carport is insession or creo

carportState = file : exists (carport)

// update the dimension

if (carportState) {

     loh = parameter : get (length_Of_House)

     dimension : set (loh * 2)

     model : regenerate

}

 

Hope that helps.

 

Dave

Highlighted

Re: Family table parameters in drawing

Awesome ... glad it worked like you expected. And yes, a server based dynamic model is just one (1) use case for CREOSON.

BTW... the relations question you asked about can also be handled by CREOSON. THAT situation is where mapkeys and trail files fail to deliver due to no interactive logic handling or operations.

A simple ... “file : relations_get” call will get the model relations and then your just need a simple check for the model name within the relations text to determine if it exists or not.

As a bonus... you can modify your relations and sent them back to the model using “file : relations_set”.

CREOSON has a TON of functionally that can be structured into whatever logic process you want.


Nitro-CELL uses the same heart of CREOSON so you can do the same operations from Excel just as easily (no coding).

Dave
Announcements