Erick's Blog
  • Home
  • Blog
  • Apps
    • Mortgage Calculator
  • PowerShell
    • Blog & Examples
    • Excel Reference
  • Windchill
    • Document Exporter
    • Document Worker
    • E.P.L.E.S.
    • Export Released
    • Property Checker
    • Windchill Business Analytics >
      • Part 01 - Program Logic
      • Part 02 - Getting Data with SQL Queries
      • Part 03 - Automating SQL Queries
      • Part 04 - Converting SQL Results to XML
      • Part 05 - Data Processing and Manipulation
      • Part 06 - Displaying XML in HTML
      • Part 07 - Auto Updating Displayed Data
      • Part 08 - Hosting Webpage with an Existing Apache Installation
      • Part 09 - Running Multiple Queries In Sequence
      • Part 10 - Calculating Data Trends
      • Part 11 - Making It Modular
    • Windchill Quick View
  • Reviews
  • Music
  • Contact

Creo 4.0 and PowerShell - Part 6: Check for Regeneration Errors and Find Missing Files

7/21/2017

2 Comments

 
Picture
Hello again Creo fans!

I've been encountering a lot of migration type work requests lately and there always seems to be issues with the data that is trying to be put into Windchill.  I have taken it upon myself to start making some high level scripts to get you going in regards to cleaning up your data before you get it into Windchill.  The first of (many?) scripts to come deals with regeneration errors and locating missing components.  Check it out and stay tuned for more.​
Initial Setup:
The very first thing you should always do before you even start thinking about moving data into Windchill is to make sure you have all of it.  I am going to assume you know how to set your config.pro "search_path" option and recommend that you set it to all known locations of where your Creo data resides.  Remember, use quotes and commas to deal with multiple paths and spaces i.e. search_path = "E:\My Creo Files", "Y:\Company Creo Files".  If you used my script from Part 5 then you should set your search_path to the latest files folder you made with it.

High Level Overview of Script:
  1. Open File.
  2. Check for Regeneration Errors.
    1. If some exist, check for top level missing parts/assemblies.
    2. Go through each sub assembly and their subassemblies, etc. and check for missing parts/assemblies if they fail regeneration.
  3. Create CSV listing the level the file is at, the filename of the missing file, and the entire hierarchy of that file leading all the way back up to the root file.
  4. Create array of missing files and row reduce i.e. same file may be missing from more than one assembly.
  5. Search given paths and their subfolders for each missing file.
    1. If more than one copy found, copy only latest modified file to given missing file directory.
    2. If no file is found, write to csv.
  6. Missing file directory is added to search path for config.pro.
  7. If all missing files are found.
    1. Regeneration is attempted and confirmed.
  8. If not all missing files are found.
    1. User must then find any left over missing files.  Partial Regeneration will yield errors so it will not be attempted.

Important:
There is no code in my script that handles drawings or regeneration errors that do not deal with missing files.  You have to figure this part out (I'm not going to give everything away).

The Regeneration Check:
In order to use the Creo API to check for regeneration issues, you must set the config.pro option "regen_failure_handling" to "resolve_mode".  It will not work otherwise.  My script will automatically do this for you.

Now, the regeneration test is fairly simple:

    
The results from a successful regeneration:
Picture
Successful Regeneration
The results from a failed regeneration:
Picture
Failed Regeneration
Unfortunately, I haven't found a way to get more details than this so you need to go through the model and find out the specific errors.  Fear not!  My script does this automatically for you (at least for missing files)!

Checking For Missing Files (missingTest Function):
This function will go through all subassemblies and find any missing parts or assemblies.  The resulting csv shows a list of the hierarchy of all missing files starting from the root file at level 0.  Below is an example of a files missing components and the resulting csv.

Locating Missing Files (findMissingFile Function):
This function cycles through all the missing files and attempts to locate them in the search paths you provide in the beginning if you tell it to search.  This will add time to the script but it makes it easier to just run it and walk away.  Three thing will happen:
  1. Found files get copied to the missing file directory you specified.
  2. Found files get added to a csv indicating their originating location called FoundFiles.csv.
  3. Remaining files are added to a MissingFiles.csv indicating files that you need to find.

Final Regeneration Test:
If the original parent assembly failed regeneration and if all missing files were found, then a 2nd and final regeneration attempt will be made.  Failure at this stage usually means regeneration issues exist that don't revolve around missing files.  You will need to perform similar tasks to try and figure it out.  This script does not account for other regeneration errors.

Final Regeneration Status Log:
At the very end, a log called "RegenLog.csv" will show to high level status of all files tested.  This is meant to be a quick summary showing the current status of each file.
Picture
Regeneration Log Showing High Level Status of All Tested Files

Now you have a new powerful tool that gives you more time to do actual work.  There are quite a few ways you can optimize this script for it to run faster but part of the fun is adding your own contributions so I won't go into anymore details.

Make sure to comment below, like, tell me about errors, etc.  I have only used this on some very controlled data and I can't imagine it running perfectly on very large and complex models.  Keep checking back for me!
Creo4RegenerationCheck.ps1

    
2 Comments
Serdar
11/30/2019 01:23:41 am

Thank you for yor information.

Reply
Jake
12/9/2020 11:33:34 am

This is amazing. Great work!

Reply



Leave a Reply.

    Author

    PLM engineer while "on the clock", programmer, designer, dreamer all other times.

    Archives

    July 2017
    May 2017
    February 2017
    January 2017
    December 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016

    Categories

    All
    ASP.NET
    Batch Script
    C#
    Career
    Computers
    Creo
    Creo API
    Flash
    GameMaker
    GitHub
    Home Loan
    How To
    HTML5
    Java
    JavaScript
    MAME
    Mortgage
    Music
    .NET Core
    Office
    PC Games
    PfSense
    PowerShell
    Reviews
    Robot
    SQL
    Video Games
    Web App
    Windchill
    Windchill API

    RSS Feed

Copyright © 2018 Erick Johnson
  • Home
  • Blog
  • Apps
    • Mortgage Calculator
  • PowerShell
    • Blog & Examples
    • Excel Reference
  • Windchill
    • Document Exporter
    • Document Worker
    • E.P.L.E.S.
    • Export Released
    • Property Checker
    • Windchill Business Analytics >
      • Part 01 - Program Logic
      • Part 02 - Getting Data with SQL Queries
      • Part 03 - Automating SQL Queries
      • Part 04 - Converting SQL Results to XML
      • Part 05 - Data Processing and Manipulation
      • Part 06 - Displaying XML in HTML
      • Part 07 - Auto Updating Displayed Data
      • Part 08 - Hosting Webpage with an Existing Apache Installation
      • Part 09 - Running Multiple Queries In Sequence
      • Part 10 - Calculating Data Trends
      • Part 11 - Making It Modular
    • Windchill Quick View
  • Reviews
  • Music
  • Contact