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,

 

Thursday, 15 January 2015

Excel ipart linking

I want to share a couple of excel tricks for retrieving data from other spreadsheets with vlookup match and error handling like when reporting #NA. We have a single excel database that contains all our part numbers, prices, description, vendor and some more info. What I wanted was to link each member in our ipart table (eventually a CC item) to our price parts list and ask excel to find our part number, place it in stock number and find the price and place it in cost center.
For simplicity I have copied the price list spreadsheet to a local path next o our library folder where we have all the components we author. This way I can work on it at home and in places where the mapped network drive is not accessible. I copy the new price list each year when it changes. I only used the price in the cost center of each item to provide a default value instead of leaving it blank.
What we intend to do is export the BOM and use the same vlookup formula to find the latest prices before doing a quote.  The price we put in CC is so we can have a value / any value, rather than leaving it blank bu we intend to update the BOM export with the vlookup formula at every export.
The tricky part was finding cells based on partial data. I have the manufacturer code, Georg Fisher part number, but in our price parts list we don’t have a cell with just GF Part number instead it holds something like this: “GF REF: 729101108” or “GF REF: 729101107  DRAIN CENTRE REF. P31127”. So all I have is 729101108 and I need to use a formula that can find a match inside a larger text and return the part number and price.



Can’t use left, right, mid, and len functions because Part Number appears randomly depending on who entered this info.
The solution is to use MATCH to find part of a text like *729101108* (* used as wildcard) and INDEX to get our Part Number value.
Once I found our part number for that item I can simply use VLOOKUP to get the price since the part number is a single unique cell value.
Here is the formula to get our Part Number (we store it in the parts Stock Number ipropertie).
=IF(ISNA(INDEX('[Price List.xls]Parts Price List'!$A$1:$A$15000,MATCH(("*"&U5&"*"),'[Price List.xls]Parts Price List'!$E:$E,0))),"",INDEX('[Price List.xls]Parts Price List'!$A$1:$A$15000,MATCH(("*"&U5&"*"),'[Price List.xls]Parts Price List'!$E:$E,0)))
Sounds complicated? Let’s brake it into simple terms.
What we’re saying is IF the value is not found (excel returns NA) then don’t put anything in the cell (“”)and if found then put the value.
=IF(ISNA(INDEX('[Price List.xls]Parts Price List'!$A$1:$A$15000,MATCH(("*"&U5&"*"),'[Price List.xls]Parts Price List'!$E:$E,0))),"",INDEX('[Price List.xls]Parts Price List'!$A$1:$A$15000,MATCH(("*"&U5&"*"),'[Price List.xls]Parts Price List'!$E:$E,0)))
MATCH(("*"&U5&"*") will actually try and find the value in cell U5 (our number 729101108 with anything before or after it in any part of the text of column E in our price list. Here is the microsoft help page.
ISNA function on microsoft’s webpage
Index is used to retrieve the value of our company’s Part Number (A row) inside our price list. Here is the microsoft help page.
The price (cost center) is much simpler.
=IF(M2="","","£"&(VLOOKUP(M2,'[Price List.xls]Parts Price List'!$A:$F,3,FALSE)))
If there is no part number (stock number) in cell M then don’t put anything but if there is a part number then add £ in front and then the value of column 3 in our price list.
Here is the VLOOKUP on microsoft webpage.
http://office.microsoft.com/en-gb/excel-help/vlookup-function-HP010343011.aspx?CTT=1
                Some experts say that the IDEX MATCH is more powerfull and faster than VLOOKUP so if possible use it at all times.
                The best explanation on how to use it and comparasson with VLOOKUP I found here:
and a couple of reasons why VLOOKUP might not work

I have attached my Georg Fischer iPart excel template for your review. I am sure it’s better to see all this at work rather than trying to understand my explanation.

Here is the excel file.

Later,
ADS


Friday, 9 January 2015

Vault Project

                Vault has not been part of my CAD up until 18 months ago and everywhere I’ve been a project file for each job has been in place. Now we only use on project for entire CAD area and while I like that I don’t need to play with changing and managing projects I do miss a couple of things. It seems all I do is browser for files and it takes longer now to do nested projects so that I can create local editable CC items. I know there is global setting for placing CC as custom but I am taking about that special times when we need to generate all the tube and pipe elements locally which otherwise would go straight to default CC folder without a local generation option.

                Having one vault project will not take you to your work in progress (just latest used location), like if you had a project for each job. I can’t edit the vaulted ipj file without affecting the rest of my colleagues so the only reasonable thing to do was to create shortcuts for the most common and current projects I work on. Nothing fancy here, just good old windows shortcuts to save me from navigating folders all day.

                So when I open or place something I click on Workspace (if I am not already there) in the left side window and then on to my shortcuts for a speedy navigation.



The fastest way for creating shortcuts is to drag with your left mouse button while holding ALT pressed the destination folder into your Workspace.




                I would only recommend you to be careful when deleting shortcuts, make sure it’s just them you’re deleting.


Later,
ADS.

Tuesday, 6 January 2015

Merry Christmas and Happy New Year

Oh wait.... is it all over?

Where has the time gone? I've missed 2 posts for the last weeks but I was in no way able to get close to a computer to hit publish.

Christmas week came loud and clear and Monday on the 22'nd of December right after midnight I was rushing at the hospital with my wife because my son decided to come to life. He was borne in the afternoon at 18:00 and the rest of the week we spend in hospital doing all sorts of tests and checks as they do on a new one.

Second week we came home but still had the 1 in 3 hours sleep routine (sometimes even less) so very little was done. We are slowly getting back to normal; I have returned to work as well so time is scarce but I will get back with those posts.

Thank you all for the kind words, mum and baby are doing fine, and I just wanted to wish you all a Happy New Year and all the best for the one ahead.

Later,
ADS