Thursday, 29 January 2015

Renumber drawing views



                If you deal with large drawings, multiple sheets, multiple views, you must have seen this one. For every view you place Inventor assigns a name “A” “B” etc. But if you start moving views around, or if for any reason you delete some of them, like doing temporary sections to check for interferences, the view name increments from the last used character. So by the time I finish the drawing I have un-sequenced drawing view names like:  “A”, “F” “M”. I finally got tired of explaining this in the workshop every time so I’ve stripped bits of code together in order to fix this.

                Here’s the code, add your own approved letters for the drawing views.


'------------------START CODE--------------- 
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

'set your view labels here
MyText = "ABCDEFHJKLMNP"
'You could have single digits numbers
'MyText = "123456789"
'have it reverse
'MyText = "z9y8x7v6u5"
'multiple characters, labels or strings
'MyText = New String(){"1","2","10","ADS","FIRST","SECOND","YOUR NAME","ETC."}

Dim i As Long
i=0

For Each oSheet In oDrawDoc.Sheets
'For Each oSheet In oSheets
    oViews = oSheet.DrawingViews
    For Each oView In oViews
        'Show the view label
        oView.ShowLabel = True
        oView.Name = "View " & MyText(i)
        i = i + 1
      Next
Next

'------------------End CODE--------------- 


Till next time,
ADS.

Thursday, 22 January 2015

Corrupted T&P assembly



                Just had a couple of more crashes and corrupted T&P assemblies and I’ve decided to share the pain, or is it the fun that I am sharing, don’t really know anymore. I seem to confuse them all the time.
                As mentioned before, if you are working with T&P environment and you seem to be getting weird results it might be because of a corrupted T&P assembly. Some of the symptoms are:
-          Importing styles reports success but not styles are present (or have been imported).
-          Styles have gone missing in styles editor (none present).
-          Changing styles will not update routes.
-          Style not persistent in all runs/routes (looks different, gap, size, appearance, etc.)
-          Cannot place fittings, onto routes or freely.
-          Any other anomalies or behaviours different than usual T&P work process.





The typical folder structure for T&P is:
1.       MAIN ASM
1.1   T&P ASM
1.1.1          Run1
1.1.1.1    Route 1
1.1.1.2    Route2
1.1.1.3    ETC.
1.1.2          Run 2
1.1.3          ETC.

You’ve got a couple of choices here and you can:
-          Use a previous version in OldVersions or in Vault history. Not really an option for those that don’t use vault and the problem might be older than the backups in OldVersions.
So now what? In short you need to create a copy of the T&P assembly, or just the runs, or just the routes, depending on where the problem is.

STEP 1:
No matter what you do the first step is to create a new context for the T&P ASM.
Option 1:
Create a copy of Main ASM under a different name and that’s because we might still need the original one to save/update original files (will get back to it in a second).
Option2:
Create a new asm , place Main ASM in it and promote all components except T&P assembly. This is to maintain constraints and relations between components.

                These options are necessary, and they will create new files for the new T&P asm, as well as all the runs and routes. I would use option 1 because with promote/demote you lose constraints of the main asm, as well as any modifications in the asm, like parameters or representations (view, position, lod)




STEP2:
                Recreate the T&P asm in the new context
                Option 1:
                - Use pace component and place the original T&P assembly here.
                - Right click on it and select “Make Adaptive”. This will create new files (copy) adaptive and activated as T&P type editable files. Make sure you have “Make all runs adaptive” ticked.
                You will lose all references and included geometry for your routes but at least you will have all files created as new in the closest possible configuration to the original one. It’s just a matter of re-constraining the routes, and re-projecting your references with “include geometry”. If the T&P was corrupted sometimes in the copy process it takes the errors with it as well so check next step.
                Option 2:
                If you still have problems with T&P then you need to repeat Step 1 and instead of placing the original T&P:
                - Create a new T&P from the Environment/Begin/Tube and Pipe.
                - Save main asm (top level)
                - Not necessary but I do go back inside T&P and delete Run1 (automatically created)
                - Use place component and place the original runs. They are asm files as well and they look like this: 150122-05.Run01.iam
                - Save main asm (top level)
                - Back to T&P and right click “Make Adaptive”
                - Repeat for all Runs.
Option3:
If you have problems with one of the runs, then:
-Recreate Step1:
- Start a new T&P environment.
- In the newly created route use place component and add all the fittings and routes in the original run.
- Do this for all runs.
- Save the main asm (top level)
- Make them adaptive.
This is the longest and most frustrating, repetitive, time-consuming option but it’s here just in case some runs go bad.
               
Things to consider if you experience corrupted files lot of times:
-          Keep the T&P template in Design Data folder clean. Don’t add any styles to it, don’t edit it, this will help you when migrating to newer versions of Inventor. Have the styles exported as xml and import them when needed in your current project. Don’t import them all, just the one you are going to use
-          Make sure you have all libraries attached to your project.
-          Keep styles consistent with Content Center (no missing libraries, corrupted family tables, proper authored pars, etc.)
-          Don’t have long folder paths. T&P as well as Design Accelerator and FEA tend to create long file paths, so keep your projects as close as possible to root drive so you don’t overpass the MS Windows limit of 256 characters.

And a short video:

 
                
 Till next time,