Tuesday 23 February 2016

Revision Table

In this post I will share what is the best method to increase the revision number on the drawing. While this can be done in several ways there are a couple of things to consider, like choosing the scope of the revision and the revision table type (single/multiple entries).



First let’s identify the different types of revisions. When you place a revision table on a drawing you will be asked if the scope of the table will be Entire Drawing or Active Sheet.

Revision Scope
If you choose Entire Drawing then all sheets will have same revision number linked to the drawing iproperties.

TIP: In the Revision Table placing window make sure that “Update Property on Revision Number Edit” is ticked.

Choosing Active Sheet will mean that each sheet will have individual revision number controlled from the sheet properties.

Sheet Revision
You might ask yourself why would one need to control revision for each sheet? It’s all to do with internal specification, document controlling and validation. Some clients have one drawing number for all sheets and some have a separate drawing number for each sheet. Think of them as separate documents each with its own part number and revision/issue number. In some industries each document needs to be tracked, linked and controlled.

TIP: Remember to change your titleblock to indicate sheet revision rather than drawing revision.

 
Titleblock Revision info
Multiple entries Revision Table:

If the company standard is to show all or predefined number of entries in the revision table (like showing last 5 changes) then know this:

                The correct way to change revision is by choosing Add Revision Row on the contextual menu when you right click the revision table but you can also do this while editing the revision table. This will update revision on the sheet or iproperties as well which in fact will update the titleblock.

Correct way to add revision
                Do not choose add row because that will not update drawing/sheet properties or the title block. The number/letter you add with the add row will not be considered as a revision number and next time you choose Add Revision Row the numbering will increment but it will ignore your manually added row value.

                Do not change iproperties manually because, even though it will update title block, this will mess up the revision table. Changing the revision number in iproperties will not increase by adding new row and it’s same as if you edit the table and change the number manually.

Single entry Revision table:

If you company standard is to show only the current row in the revision table then changing iproperties might be your preferred choice. Entering a value in iproperties will override the last row in the table and will update the title block.

TIP: Remember that you can open iproperties from the revision table but even faster you can bring them up by right clicking the drawing name in the tabs or in the browser like this:
               
Getting the iProperties window.

                Either way you choose to use this I hope I gave you some good info to speed up your workflow.

Later,
ADS




photo credit: Woolpit Steam (license)

Thursday 18 February 2016

One LOD To Rule Them All

NEVER use more than on LOD (Level of Detail) in the drawing, especially for large assemblies.


I see this problem ALL THE TIME, new or experienced users so, even if it’s not a proper blog I need to get this out… you all need to know, understand and remember this.

LOD is a memory tool not to be used in the drawings. Each LOD will load in to memory all the parts as if they were new parts even if they are just occurrences (duplicates).

Say you have an assembly of 1000 parts and you create a LOD where you suppress 1 element. If you use these two LOD’s on separate views in the same drawing then the number of occurrences will be 1000 + 999 = 1999 instead of 1000. Inventor treats each LOD as a separate assembly in the drawing!!!!



You will see a huge increase in size and you will impact performance severely.

Use Design View Representations to document different views and if you need to use LOD then have one per drawing (all sheets) like “All Content Center Suppressed” and differentiate the changes with Design View Representations.

                Now you can filter Parts List for “Design View Representation” and document a specific configuration on each Parts List but the Quantity will come from the full assembly (2017 has a fix on this).

                For now, to fix the quantity you need to look at iAssemblies. My notes on this here.

                Take a look at Large Assembly Instructions.pdf.

                You might want to suppress some of the views and turn them on when you need to work on them.

Now, repeat after me: “I swear to use only one LOD for each drawing, cross my hart and hope Inventor crashes if not”.


Later,

ADS



photo credit: Vanishing Point (license)

Wednesday 17 February 2016

Rounding Parameters, Part 2

If you have been struggling to use parameter functions like round, ceil, floor, isolate (which converts units for parameters) or similar then you will need to know this. I have been playing with this before and it was only recently that I have found some hidden help pages which explain why I had this problem and how to solve it.

round'n round


The more you live the mode you learn and I hope it stays this way for a long time; I know there is a regression curve but I don’t want to taste it. Avid for knowledge I am glad I learned something new so I had to write it down for you and me; I am in this way hoping it won’t perish in the back of my mind.

The solution I found last time was to increase precision by multiplying with10 or one if it’s powers, then use the function and then divide by that number again. Not elegant or good looking but it did the trick until I found the correct solution for this.

So it seems that units are evaluated before mean value of the parameter and in order to evaluate the numerical part you first need to get rid of the units.

How do we do that? We simply divide and multiply by the parameter units like this: "round(5.8 / 1 mm) * 1 mm"

Get rid of those units first.

The help page has a probably better example so shamelessly I will share it.

Units are evaluated before the arithmetic portion of an expression. Therefore, the power operator applies to a unit before it applies to an adjacent numeric value. For example:
2 m^2
does not evaluate to 4 square meters, but rather means 2 square meters. The correct syntax is:
(2 m)^2 = 4 m^2

There is a lot of info about syntax errors as well like when you mix units with unitless values without explicitly specifying this. That’s when you get that red text in the functions window so make sure you glimpse over the help pages here (2016) or here (2014), if the page is no more, search Google for “Formulas and equations for expressions reference” or “Expression Reference for Numeric Parameters”.

Later,

Ads.



photo credit: snowing (license)

Tuesday 9 February 2016

Item Number on Drawing Views (Reg Hasell update)

                Do you remember the “Item Number on Drawing Views” blog? It was a while back and if you need a refresh you can read it in full here, but essentially it will add the Item Number on drawing views. If you are detailing components and assemblies on same drawing then this will rename the component view description and will add the Item Number as indicated in Parts List and Balloon.

Our ilogic code looks the same now!
                I have an updated code for which all the credits go to Reg Hasell. As it usually happens “one size doesn’t fit all” and he needed a personalized code which removes orphaned views and also changes formatting of the view labels. Sometimes we need to remove views of items no longer on the Parts List and that can be done with ilogic as well.

                If you find this useful, go to autodesk forum, find him and give him kudos For questions you can start a new thread on the Inventor Customization Forum and then call me or him by adding our usernames in the post like this: @salariua @rhasell. I am sure Reg wouldn’t mind answering questions about his changes, if he has the time for it.

                I have asked Reg to give us a short description about himself, the work he does and why the need to change the code. Here he goes:

------------------------------------------------------------------------------------------------------------
Hi all,
Very briefly about me.

                I am originally from South Africa and moved to the Gold Coast Australia 5 years ago with my Wife and Daughter. I currently work for a small company that design Tension membrane structures. (EG The fabric roof over the stadiums) and most of my work is structural steel.

                I started as an Application Engineer with an Autodesk VAR about 10 years ago and have taught myself pretty much everything. I only really started to learn Inventor when I moved to an engineering firm and all of a sudden your designs are being built!

                When I moved to Australia I had to really pull out the stops when it came to 'tweaking' Inventor. All our drawing standards are Architectural based, and Inventor does not play nicely. It took me about 12 months to find my groove.

                If I follow my trend on the forums, I can see how I have grown from asking to helping. I still strive accepted solutions and Kudos. I feel I that I bring a real world experience to the forums, as all my solutions come from practical experience and lots of blood sweat and tears.

                The "Delete me code" has also grown up a little, as there was a slight bug in that it changed everything to "Delete me" Including views that I did not want to change. Depending on the drawing type, this did not pose an issue, but on smaller assembly drawings where I share the assembly detailing with component detailing this became a problem. Some larger assembly drawings have their own component detailing sheets. So it now allows me to select the views I want to change.

                I created this code because I re-use a lot of assemblies, (E.G I will make a master Sub-Assembly, and just add cleats etc for each variation, and their drawings, obviously with a few small changes. When it came to detailing the items, I use the feature of "Replace Model Reference" Sometimes it’s difficult to keep track of what is on your drawing sheet, and mistakes are made.

------------------------------------------------------------------------------------------------------------

Thanks Reg for this short description / interview and for the updated code.

Enough said, here is Reg’s code, and even if you don’t use this feature I suggest you glimpse over because there is a lot of good info you could be using somewhere else.



--------------------------Start “Drawing_View_Label”--------------------------
'Set view Label
Sub Main oView
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
    MessageBox.Show("At least 1 drawing view must be selected first", "iLogic")
Exit Sub
End If

'Removed 27.01.2016 Reg Hasell
'Was not really achiving anything.

'Reference to the drawing view from the 1st selected object
''Dim oView As DrawingView= trycast(oSSet.item(1), DrawingView)
''oModel = ThisDoc.ModelDocument
''If oView IsNot Nothing Then
''oView.ShowLabel = True
oMenu ()
''End If
End Sub

Sub oMenu
Dim resu1t As String="Result"
Dim oLab As New ArrayList
oLab.Add("Single Assy")
oLab.Add("Mirror Assy")
oLab.Add("Extrusion - Item")
oLab.Add("Extrusion - Mirrored")
oLab.Add("")
oLab.Add("Detail Item")
oLab.Add("")
oLab.Add("Section View")
oLab.Add("Detail View")
oLab.Add("Plan View")
oLab.Add("Axonometric View")
oLab.Add("")
oLab.Add("Elevation")
oLab.Add("Flat Pattern")

'Display table and get the selection
resu1t=InputListBox("Select View Label", oLab, resu1t, _
Title := "View Label Choice", ListName := "View Label")

'Set iProperties based on the selection.
If resu1t="Single Assy" Then
Call oSingle

ElseIf resu1t="Mirror Assy" Then
Call oMirror

ElseIf resu1t="Extrusion - Item" Then
Call oExtrusion

ElseIf resu1t="Extrusion - Mirrored" Then
Call oExtrusion_M

ElseIf resu1t="Detail Item" Then
Call oDetail

ElseIf resu1t="Section View" Then
Call oViewSect

ElseIf resu1t="Detail View" Then
Call oViewDet

ElseIf resu1t="Plan View" Then
Call oViewPlan

ElseIf resu1t="Axonometric View"
Call oViewAxon

ElseIf resu1t="Elevation" Then
Call oViewelevation

ElseIf resu1t="Flat Pattern" Then
Call oViewFlat

End If
End Sub

Sub oSingle
'Set view Label
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
''If oSSet.count = 0 Then
''    MessageBox.Show("You must select a drawing view first", "iLogic")
''Exit Sub
''End If
'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView= trycast(oSSet.item(1), DrawingView)
oModel = ThisDoc.ModelDocument
If oView IsNot Nothing Then
oView.ShowLabel = True

Call project
'MessageBox.Show(iProperties.Value("Project", "Project"), "Title")

oProject=iProperties.Value("Project", "Project")       
        oItemValue= oProject & "_QTY"
'MessageBox.Show(oItemValue, "Title")
'Sub Set properties to create the Custom Fields, Without going into too much detail, I can't do this in one step

o_iPropID_QTY = oModel.PropertySets.Item("User Defined Properties").Item(oitemValue).PropId 'Custom QTY Field, defined above
o_iPropID_ENG = oModel.PropertySets.Item("User Defined Properties").Item("ENG").PropId

'format the model iproperties
    oStringQTY = "<StyleOverride Underline='True' FontSize='0.5' Bold='True'><Property Document='model' PropertySet='User Defined Properties' Property='customPropertyName' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
     & o_iPropID_QTY & "'>customPropertyName </Property></StyleOverride>"
    
     oStringENG = "<StyleOverride Underline='True' FontSize='0.5' Bold='True'><Property Document='model' PropertySet='User Defined Properties' Property='customPropertyName' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
     & o_iPropID_ENG & "'>customPropertyName </Property></StyleOverride>"

    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'> OFF - AS SHOWN - MARK AS - </StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"

'add to the view label
oView.Label.FormattedTextoStringQTY & oStringTXT & oStringENG & oStringScale
Else
    MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If
'If Not oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft Then
'        oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
'    End If
Align ()
End Sub

Sub oMirror
'Set view Label
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
''If oSSet.count = 0 Then
''    MessageBox.Show("You must select a drawing view first", "iLogic")
''Exit Sub
''End If
'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView= trycast(oSSet.item(1), DrawingView)
oModel = ThisDoc.ModelDocument
If oView IsNot Nothing Then
oView.ShowLabel = True
' set up the the project number for the drawing label
Call project

oProj=iProperties.Value("Project", "Project")
oItemValue= oProj & "_QTY"

o_iPropID_QTY = oModel.PropertySets.Item("User Defined Properties").Item(oitemValue).PropId 'Custom QTY Field, defined above
o_iPropID_ENG = oModel.PropertySets.Item("User Defined Properties").Item("ENG").PropId

'format the model iproperties   
oStringQTY = "<StyleOverride Underline='True' FontSize='0.5' Bold='True'><Property Document='model' PropertySet='User Defined Properties' Property='customPropertyName' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
     & o_iPropID_QTY & "'>customPropertyName </Property></StyleOverride>"

     oStringENG = "<StyleOverride Underline='True' FontSize='0.5' Bold='True'><Property Document='model' PropertySet='User Defined Properties' Property='customPropertyName' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
     & o_iPropID_ENG & "'>customPropertyName </Property></StyleOverride>"

    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'> OFF - AS SHOWN - MARK AS - </StyleOverride>"
    oStringOPP = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'> OFF - OPPOSITE HAND - MARK AS - </StyleOverride>"
    oStringTXTx = "<StyleOverride Underline='True' FontSize='0.5' Bold='True'>x </StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"
    oReturn="<Br/>"

'add to the view label
oView.Label.FormattedTextoStringQTY & oStringTXT & oStringENG & oReturn & oStringQTY & oStringOPP & oStringENG & oStringTXTx & oStringScale
Else
    MessageBox.Show("The selected object is not a drawing view", "iLogic")
    End If
Align ()
End Sub

Sub oExtrusion ' Added by Reg 27.01.2016
'''Set view Label
''Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
''Dim oView As DrawingView= trycast(oSSet.item(1), DrawingView)
''oModel = ThisDoc.ModelDocument
''If oView IsNot Nothing Then
''oView.ShowLabel = True
Dim oView As DrawingView
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet 'Added rev 2.0 - Selection

oModel = ThisDoc.ModelDocument
    For Each oView In oSSet

Call project
'MessageBox.Show(iProperties.Value("Project", "Project"), "Title")

oProject=iProperties.Value("Project", "Project")       
        oItemValue= oProject & "_QTY"
'MessageBox.Show(oItemValue, "Title")
'Sub Set properties to create the Custom Fields, Without going into too much detail, I can't do this in one step

o_iPropID_QTY = oModel.PropertySets.Item("User Defined Properties").Item(oitemValue).PropId 'Custom QTY Field, defined above
o_iPropID_ENG = oModel.PropertySets.Item("User Defined Properties").Item("ENG").PropId

'format the model iproperties
    oStringQTY = "<StyleOverride Underline='True' FontSize='0.5' Bold='True'><Property Document='model' PropertySet='User Defined Properties' Property='customPropertyName' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
     & o_iPropID_QTY & "'>customPropertyName </Property></StyleOverride>"
    
     oStringENG = "<StyleOverride Underline='True' FontSize='0.5' Bold='True'><Property Document='model' PropertySet='User Defined Properties' Property='customPropertyName' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
     & o_iPropID_ENG & "'>customPropertyName </Property></StyleOverride>"

    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'> OFF - AS SHOWN - MARK AS - </StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"

'add to the view label
oView.Label.FormattedTextoStringQTY & oStringTXT & oStringENG & oStringStock & oStringScale

''Else
''    MessageBox.Show("The selected object is not a drawing view", "iLogic")
''End If
'If Not oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft Then
'        oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
'    End If
Align ()
Next
End Sub

Sub oExtrusion_M ' Added by Reg 27.01.2016
'Set view Label
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
''If oSSet.count = 0 Then
''    MessageBox.Show("You must select a drawing view first", "iLogic")
''Exit Sub
''End If
'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView= trycast(oSSet.item(1), DrawingView)
oModel = ThisDoc.ModelDocument
If oView IsNot Nothing Then
oView.ShowLabel = True

Call project
'MessageBox.Show(iProperties.Value("Project", "Project"), "Title")

oProject=iProperties.Value("Project", "Project")       
        oItemValue= oProject & "_QTY"
'MessageBox.Show(oItemValue, "Title")
'Sub Set properties to create the Custom Fields, Without going into too much detail, I can't do this in one step

o_iPropID_QTY = oModel.PropertySets.Item("User Defined Properties").Item(oitemValue).PropId 'Custom QTY Field, defined above
o_iPropID_ENG = oModel.PropertySets.Item("User Defined Properties").Item("ENG").PropId

'format the model iproperties
    oStringQTY = "<StyleOverride Underline='True' FontSize='0.5' Bold='True'><Property Document='model' PropertySet='User Defined Properties' Property='customPropertyName' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
     & o_iPropID_QTY & "'>customPropertyName </Property></StyleOverride>"
    
     oStringENG = "<StyleOverride Underline='True' FontSize='0.5' Bold='True'><Property Document='model' PropertySet='User Defined Properties' Property='customPropertyName' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
     & o_iPropID_ENG & "'>customPropertyName </Property></StyleOverride>"

    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringOPP = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'> OFF - OPPOSITE HAND - MARK AS - </StyleOverride>"
    oStringTXTx = "<StyleOverride Underline='True' FontSize='0.5' Bold='True'>x </StyleOverride>"

    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'> OFF - AS SHOWN - MARK AS - </StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"
    oReturn="<Br/>"

'add to the view label
oView.Label.FormattedTextoStringQTY & oStringTXT & oStringENG & oReturn & oStringQTY & oStringOPP & oStringENG & oStringTXTx & oStringStock & oStringScale
'oStringQTY & oStringTXT & oStringENG & oReturn & oStringQTY & oStringOPP & oStringENG & oStringTXTx & oStringScale
Else
    MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If
'If Not oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft Then
'        oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
'    End If
Align ()
End Sub

Sub oDetail
Dim oView As DrawingView
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet 'Added rev 2.0 - Selection

oModel = ThisDoc.ModelDocument
    For Each oView In oSSet

'format the model iproperties   
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>ITEM <DrawingViewName/> DETAIL </StyleOverride>"
    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"

'add to the view label
oView.Label.FormattedTextoStringTXT & oStringStock & oStringScale
'Else
'    MessageBox.Show("The selected object is not a drawing view", "iLogic")
'End If
If Not oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft Then
        oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
    End If
    Next
End Sub

Sub oViewSect
Dim oView As DrawingView
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet 'Added rev 2.0 - Selection

oModel = ThisDoc.ModelDocument
    For Each oView In oSSet

'format the model iproperties   
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>SECTION  </StyleOverride>"
'    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"

'add to the view label
oView.Label.FormattedTextoStringTXT & oStringScale
Align ()
Next
End Sub

Sub oViewDet
'Detail view Label Reset
Dim oView As DrawingView
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet 'Added rev 2.0 - Selection

oModel = ThisDoc.ModelDocument
    For Each oView In oSSet

'format the model iproperties   
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>DETAIL  </StyleOverride>"
'    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"

'add to the view label
oView.Label.FormattedTextoStringTXT & oStringScale
Align ()
Next
End Sub

Sub oViewPlan
'Detail view Label Reset
'Set view Label
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView= trycast(oSSet.item(1), DrawingView)
oModel = ThisDoc.ModelDocument
If oView IsNot Nothing Then
oView.ShowLabel = True

'format the model iproperties   
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>PLAN VIEW  </StyleOverride>"
'    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"

'add to the view label
oView.Label.FormattedTextoStringTXT & oStringScale

Else
    MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If
Align ()
End Sub

Sub oViewAxon
'Detail view Label Reset
'Set view Label
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView= trycast(oSSet.item(1), DrawingView)
oModel = ThisDoc.ModelDocument
If oView IsNot Nothing Then
oView.ShowLabel = True

'format the model iproperties   
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>AXONOMETRIC VIEW  </StyleOverride>"
'    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE N.T.S</StyleOverride>"

'add to the view label
oView.Label.FormattedTextoStringTXT & oStringScale

Else
    MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If
Align ()
End Sub

Sub oViewelevation
'Detail view Label Reset
'Set view Label
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView= trycast(oSSet.item(1), DrawingView)
oModel = ThisDoc.ModelDocument
If oView IsNot Nothing Then
oView.ShowLabel = True

'format the model iproperties   
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>ELEVATION  </StyleOverride>"
'    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"

'add to the view label
oView.Label.FormattedTextoStringTXT & oStringScale

Else
    MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If
Align ()
End Sub

Sub oViewFlat
'Detail view Label Reset
'Set view Label
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView= trycast(oSSet.item(1), DrawingView)
oModel = ThisDoc.ModelDocument
If oView IsNot Nothing Then
oView.ShowLabel = True

'format the model iproperties   
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>ITEM FLAT PATTERN  </StyleOverride>"
'    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"

'add to the view label
oView.Label.FormattedTextoStringTXT & oStringScale

Else
    MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If
Align ()
End Sub



Sub Align
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView
For Each oView In oSheet.DrawingViews
    If Not oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft Then
        oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
    End If
Next
End Sub

Sub Project
oProject = InputBox("Change Project Name", "Project Name", iProperties.Value("Project", "Project"))
        iProperties.Value("Project", "Project")=oProject
Return
End Sub

--------------------------End “Drawing_View_Label”--------------------------

--------------------------Start “IDW Reset Labels” Rev1--------------------------
 
'Reg
'Version 1.0
'Date: 13/10/15
 
'This code renames all the views on a drawing
'to match the item number in the model tree.
'It then formats the label correctly to suit GDI.
 
' 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 Sheet As Inventor.Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Dim oProj As String
oModel = ThisDoc.ModelDocument
 
 
'oProj = InputBox("Project number", "Title", "15046")
'oItemValue= oProj & "_QTY"
'MessageBox.Show(oProj, "Title")
'MessageBox.Show(oItemValue, "Title")
 
 
 
 
For Each oSheet In oDrawDoc.Sheets
'For Each oSheet In oSheets
    oViews = oSheet.DrawingViews
    For Each oView In oViews
'Show View Label if switched off
oView.ShowLabel = True
'Sub Set to create the Custom Field
oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>DELETE ME <DrawingViewName/></StyleOverride>"
    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"
 
'add to the view label
oView.Label.FormattedTextoStringTXT & oStringStock & oStringScale
 
  If Not oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft Then
        oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
    End If
                    
                    
                    
'                                    End If  
'            Next
      Next
Next
 
--------------------------End “IDW Reset Labels” Rev1--------------------------

--------------------------Start “IDW Reset Labels” Rev2--------------------------
 
'Reg
'Version 2.0
'Date: 27/01/16
 
'This code renames all the selected views on a drawing
'to "Delete Me"
'When re-using drawings, sometimes views becomeorphaned, and they get missed.
'This is a two stage process of renaming the views, then naming them to their correct vaules.
'Anything left as a "Delete Me" label, can be deleted.
'The origional code renamed every view on the drawing. (I will note what can be commented out to re-enable this feature)
'This unfortunately re-named Valid view labels as well, and was quite tedious to rename everything back again.
 
'Change history:
'Version 2.0 (27.01.2016)
'Added the feature of renaming selected views only.
 
' 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 Sheet As Inventor.Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Dim oProj As String
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet 'Added rev 2.0 - Selection
oModel = ThisDoc.ModelDocument
 
'Check that at least one view is selected
If oSSet.count = 0 Then
MessageBox.Show("At least 1 drawing view must be selected first", "iLogic")
End If
 
For Each oSheet In oDrawDoc.Sheets
'For Each oSheet In oSheets
    oViews = oSheet.DrawingViews
    'For Each oView In oViews ' Removed by Rev 2.0
    For Each oView In oSSet ' Added in Rev2.0
 
'Nothing Fancy, a basic view label text line.
oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>DELETE ME <DrawingViewName/></StyleOverride>"
    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"
'add to the view label
oView.Label.FormattedTextoStringTXT & oStringStock & oStringScale
 
'This is not really needed, but left in anyway to format the Alignment.
  If Not oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft Then
        oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
    End If
      Next
Next

--------------------------End “IDW Reset Labels” Rev2--------------------------

--------------------------Start “IDW Set Item Number”--------------------------

'Firstly: Credit goes to "Adrian Salariu" for all the help
' http://blog.ads-sol.com/
' https://plus.google.com/+AdrianSalariu-ADS
' He wrote the main section of the code, I just added the GDI label formats.
' using snippets regarding the type formats, I added the differnt types of views.
'Reg Hasell
'Version 2.0
'Date: 19/11/15
 
'This code renames all the views on a drawing
'to match the item number in the BOM.
'It then formats the label correctly to suit GDI.
'-----------------------------------------------------------
' 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 Sheet As Inventor.Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
 
For Each oSheet In oDrawDoc.Sheets
'For Each oSheet In oSheets
    oViews = oSheet.DrawingViews
    For Each oView In oViews
    
        'Get the full filename Of the view model
        Dim oModelFileName As String
        oModelFileName = oView.ReferencedDocumentDescriptor.ReferencedDocument.FullFileName
        'MessageBox.Show("view model name" & oModelFileName, "Title")
 
        Dim oPartList As PartsList
            'try and get the parts list form the table of this sheet
            Try
                oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
            Catch 'on error try and search all sheets for first found parts list            
                'iterate trough each sheet
                Dim i As Long
                For i = 1 To oDrawDoc.Sheets.Count
                    If oDrawDoc.Sheets.Item(i).PartsLists.Count > 0 Then Exit For
                Next    
                oPartList = oDrawDoc.Sheets.Item(i).PartsLists.Item(1)
                'MessageBox.Show("parts list found on: " & i, "Title")
            End Try
                
            ' Iterate through the contents of the parts list.
            Dim j As Long
            For j = 1 To oPartList.PartsListRows.Count
                ' Get the current row.
                Dim oRow As PartsListRow
                oRow = oPartList.PartsListRows.Item(j)
                'get filename of model in row
                Dim oRowFileName As String
                oRowFileName = oRow.ReferencedFiles.Item(1).FullFileName
                'compare the filenames
                'Performs a text comparison, based on a case-insensitive text sort order
                'If strings equal returns 0
                If StrComp(oModelFileName, oRowFileName, CompareMethod.Text)=0 Then 
                    'Get the value of Item from the Parts List
                    'Row name needs to be case sensitive or use 1 for first 2 for second etc.
                    oCell  = oPartList.PartsListRows.Item(j).Item("Item") 'Row name needs to be case sensitive or use 1 for first 2 for second etc.
                    'get the value of text in cell
                    Dim oItemValue As String
                    oItemValue = oCell.Value
                    
                    'Show the view label
                    'oView.ShowLabel = True
                    'format the text first line
                
                'REG
    ' ITEM " & oItemValue & " ](REG TESTING)
    'oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>ITEM <DrawingViewName/> DETAIL </StyleOverride>"
    
    If oVIEW.Viewtype=10501 Then '(Checks for primary views only)
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>ITEM " & oItemValue & " DETAIL </StyleOverride>"
    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"
    'add to the view label
    oView.Label.FormattedTextoStringTXT & oStringStock & oStringScale
 
ElseIf oVIEW.Viewtype=10503 Then '(Section View Type)
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>SECTION  </StyleOverride>"
    'oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"
    'add to the view label
    oView.Label.FormattedTextoStringTXT & oStringScale
 
ElseIf oVIEW.Viewtype=10502 Then '(Detail view type)
    oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>DETAIL  </StyleOverride>"
'    oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
    oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE <DrawingViewScale/></StyleOverride>"
'    add to the view label
    oView.Label.FormattedTextoStringTXT & oStringScale
 
ElseIf oVIEW.Viewtype=10504 Then '(Isometric view Type)
    oView.ShowLabel = False ' Switch off the label Remove the comments below to enable axonommetric
        'oStringTXT = "<StyleOverride Underline='True' FontSize='0.5' Bold='False'>AXONOMETRIC VIEW  </StyleOverride>"
        'oStringStock = "<Br/><StyleOverride FontSize='0.25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='55'>STOCK NUMBER</Property></StyleOverride>"
        'oStringScale = "<Br/><StyleOverride FontSize='0.25'>SCALE N.T.S</StyleOverride>"
        'add to the view label
        'oView.Label.FormattedText =  oStringTXT & oStringScale
 
        End If
'add to the view label '(removed as it has now been replaced by the individual formats)
'oView.Label.FormattedText =  oStringTXT & oStringStock & oStringScale
'LEFT Align View Labels
If Not oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft Then
        oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
    End If
 
 
                End If  
            Next
      Next
Next
'All done, thanks once again to Adrian.

--------------------------End “IDW Set Item Number”--------------------------

Later,
ADS

photo credit: Codex Hammurabi, Louvre, Paris (license)