Friday, 28 July 2017

Multiple Balloon Sets

                How can I have multiple balloon sets on same drawing? How can show project Item Number on components and subassembly drawings?



                In this case the user wanted to have dual balloons on all drawings but it works with as many balloons as you can fit in a drawing.

The first balloon will indicate current assembly Item Number, which translates to what position the item has in the current assembly and the second balloon was to show master Item Number which means what position this member has in the general, whole project, context.

He didn’t want to have dual set of documentation, one for fabrication and one for manuals because it was hard for him to maintain and update.

Three things are needed for this.

The user will place balloons on drawing as usual and we will change them for him but in order to do that we need a way of knowing which ones exactly he needs changing.

1. A new balloon style called “Pars Only”. I suggest you change the shape as well, like hexagonal type, maybe change text style too just to distinguish them better and update the code if you use a different name for the balloon.



2. A “PARTS ONLY” table but of the main assembly. Name it whatever you want but update the code.

User needs to place main assembly (project) “PARTS ONLY” parts list on the drawing so we can track and find this.

Do not filter the Parts Only table, it won’t work, there is no view for it to process. Design View reps or Ballooned Only filters won’t work.

3. iLogic code to process all “Parts Only” balloons and update value as in “PARTS ONLY” table.

You can do this with without a table but have the user browser for main iam and process BOM from that.

Here is a short video:

video


And here is the iLogic code:

'  Set a reference to the drawing document.

' This assumes a drawing document is active.

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

' Set a reference to the active sheet.
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet

Dim oStyles As DrawingStylesManager
oStyles = oDrawDoc.StylesManager

Dim oCurve As DrawingCurve
'Dim oEdge As EdgeProxy
Dim oOccurrence As ComponentOccurrence 
Dim oGeometryIntent As GeometryIntent

'----------Update existing balloons on all sheets

'Ask the user if he wants to update values of all balloons (if edited some)
booleanParam = InputRadioBox("Update Parts Only balloons?: ", "Yes", "No", True, Title :="Update?")

If booleanParam = False Then
    Exit Sub
ElseIf booleanParam = True
End If

Dim oSheet As Sheet
'process all sheets
For Each oSheets In oDrawDoc.Sheets 
    
    '----------find the parts list
    oPartsLists = oActiveSheet.PartsLists
    'try and get the parts list form the table of this sheet
    Try
        
        For i=1 To oPartsLists.Count
            If oPartsLists.Item(i).Title = "PARTS ONLY" Then
                oPartsList = oPartsLists.Item(i)
                Exit For
            Else
                'do nothing
            End If
        Next
    Catch
        MessageBox.Show("No parts list named 'PARTS ONLY' found on drawing", "iLogic")
    End Try    

'----------end finding parts list

    ' Iterate over each balloon on the sheet.
    For Each oBalloon In oActiveSheet.Balloons
        If oBalloon.Style.Name = "Parts Only" Then
            Try
                Dim leader As Leader
                Leader = oBalloon.Leader
                'assuming the leader is a single line segment
                Dim leaderNode As LeaderNode 
                leaderNode = leader.AllNodes(2)
                
                oGeometryIntent = leaderNode.AttachedEntity
                curve = oGeometryIntent.Geometry
                oEdge = curve.ModelGeometry
                oOccurrence = oEdge.ContainingOccurrence
                
                'get the selected item document occurrence name
                oOccDoc = oOccurrence.Definition.Document
                
                'get the path and file name of the selected item
                oOccFileName = oOccDoc.FullFileName
                
                ' Iterate over each value set (attached balloons) in a balloon.
                For Each oBalloonValueSet In oBalloon.BalloonValueSets
                    
                    '----------find item in parts list PARTS ONLY
                    ' Iterate through the contents of the parts list.
                    Dim j As Long
                    For j = 1 To oPartsList.PartsListRows.Count
                        ' Get the current row.
                        Dim oRow As PartsListRow
                        oRow = oPartsList.PartsListRows.Item(j)
                        'get filename of model in row
                        Dim oRowFileName As String
                        Try ' try and get the full file name of the PL item
                            oRowFileName = oRow.ReferencedFiles.Item(1).FullFileName
                        Catch 'on error go to next item
                            Continue For
                        End Try
                        
                        'compare the filenames
                        'Performs a text comparison, based on a case-insensitive text sort order
                        'If strings equal returns 0
                        If StrComp(oOccFileName, 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  = oPartsList.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
                            
                            '------------change balloon value to Parts ONLY Item value
                            oBalloonValueSet.OverrideValue = oItemValue
                        
                        End If
                    'go to next row in table
                    Next
                    '----------end find item in parts list PARTS ONLY                
                    
                Next 'go to next attached balloon in set
            Catch'do nothing if error
            End Try
        End If 'end of search for Tags balloons
    Next
Next

'----------End Update existing balloons on all sheets



Later,
ADS
photo credit: Donahos Balloons over Colorado (license)

Tuesday, 25 July 2017

Precise Circular Text Pattern

                Do you need a Precise Circular Text Pattern?

                I needed this the other day and I was a bit intrigued about the best workflow for this.



                I needed this the other day and I was a bit intrigued about the best workflow for this.

                My first thought was to do it with iFeatures. Create a prompted text iFeature and a pattern of sketch points and place this iFeature as many times as you need changing the text every time. 

                Whell... that didn’t work and I slowly realized that it will be very difficult to edit, not to mention the large number of features in the browser.

                Then I thought of doing it by creating them as separate features and wrap them to the part. This seemed complicated as well so I had a better idea.

                Create a text and emboss it to the face, except there is a trick here. In order to get exact spacing between first and last, you need to use “Exact Spacing” in the text editor.

                This way I can control the text size and yet still get precise placement.

                As always Inventor threw a spanner in the works because the exact spacing field text has only 2 (two) decimal settings and you can’t use parameter for an automatic update when you change drum diameter.

                This was still way better than any other solutions proving fast and simple.

                The original screencast can be seen here (includes commands and dialog boxes if the video bellow is not clear enough).




Later,

ADS


photo credit: Simon & His Camera Darkest Before Dawn by Simon & His Camera (license)

Friday, 21 July 2017

Precise Move Table

                Do you need to enforce Revision Table position? or any table for that matter?

                We talked about how to place and locate various tables on drawings so this is not new info but it is best if we make a post of its own so you can find it faster.

                This will help you enforce common standard and procedures when working with new recruits/students/temporary workforce.

                The code will move your revision table to lower left corner of your sheet but I did touch on how to find and use other points on drawing.



I did play with “TableDirection” “kBottomUpDirection” & “kTopDownDirection” thinking that the point coordinates will change depending on the drawing style of the table but Inventor outsmarted me (that’s not hard) and worked perfectly out of the box.

                It seems table coordinates will always start from top left corner no matter of your header position (top/bottom) or table direction (bottom up / top down), so we do need to calculate the height of the table.

On this principle, you can play with “Border.RangeBox.MinPoint”  ”Border.RangeBox.MaxPoint” or even specific x y values “Border.RangeBox.MinPoint.X” “Border.RangeBox.MinPoint.Y” to locate it in a different corner.

                This also applies to “TitleBlock.Position” or “TitleBlock.RangeBox” in case you need it next to, or on top of the titleblock.

                You can even search for table specific name if you have more than one tables on the sheet, that’s not possible with revision tables but it is with custom tables.  For example, this will search for Parts List with specific Title:

For i=1 To oPartsLists.Count
    If oPartsLists.Item(i).Title = "PARTS LIST" Then
        oPartsList = oPartsLists.Item(i)
        Exit For
Next

                So here is the code to move Revision Table:

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

'if you want different positions youcan get the MinPoint.X or MaxPoint or MaxPoint.Y
'along those lines
Dim oBorderPt As Point2d
oBorderPt = oSheet.Border.RangeBox.MinPoint

Dim oRevTable As RevisionTable
'I assume you only have 1 rev table on the drawing
oRevTable = oSheet.RevisionTables.Item(1)

Dim oRevPt As Point2d
oRevPt = ThisApplication.TransientGeometry.CreatePoint2d _
            (oBorderPt.X, oBorderPt.Y  + (oRevTable.RangeBox.MaxPoint.Y - oRevTable.RangeBox.MinPoint.Y))

oRevTable.Position = oRevPt

Later,
ADS
               

                

Tuesday, 18 July 2017

Add Legend to Parts List

Can we add a legend to our drawing PartsList?


You can add a Custom Part on your Parts List or you can add a Virtual Part in the assembly but those will obey the Parts List format and you can’t merge the cells into a single one. I don’t suggest you add Virtual Part to BOM anyway because it will show up higher up in assemblies and I doubt anyone would want that.

What other options we have?

Create a symbol which you call and place every time. If you set the leader visible “off” it will look like a bit of text floating around but the invisible leader will allow you to attach it to views, or other elements and it will move with those by magic.

Some prefer to hardcode it on the border or titleblock but that doesn’t allow for much customization except if you use a prompted entry type field.

I don’t expect anyone to follow this but you can also manage your entire Parts List in Excel and after adding the legend to the bottom, you can place the spreadsheet as custom table on the drawing.

All this being mentioned you can add your Legend to your Parts List Title which is a single cell but you need to format your code in word, or other text editing software or even better have an iLogic code to do that for you.

If you are not iLogic fan then you can type your text in word, copy it and paste it in the Title field in Parts List editor but the next code is very easy, just give it a try...



Here is the iLogic code to add a Legend to your ParsList. It has a preset list already but it accepts user prompted values as well.

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

Dim oPartsLists As PartsLists

' Process the rule, wrapping it in a transaction so the 
' entire process can be undone with a single undo operation. 
Dim trans As Transaction 
trans = ThisApplication.TransactionManager.StartTransaction( _ 
        oDrawDoc, "Change Title of Parts List")
    
    'I assume you ony have one Parts List on the sheet
    
    'get current title
    oPartsLists = oSheet.PartsLists
    oTitle = oPartsLists.Item(1).Title
    
    'ask for Legend
    oLegend = InputBox("Enter Legend", "Legend", "Mach=Machined, Fab=Fabricated")

    
    'set title
    oNewTitle = oTitle + _
                vbLf + _
                vbLf + oLegend
                
    oPartsLists.Item(1).Title = oNewTitle
    
'finish the transaction
trans.End 


Later,
ADS


Friday, 14 July 2017

Align Drawing Views

So.. What’s happening? Not much! decided to give a hand on Inventor Forum so I was quite busy there but good things emerge like this post about how to align drawing views.


In this case, the user wanted to place multiple parts on the same drawing and align them left side for visual comparison.

                When is this useful? How about progressive die sheet metal parts?

                Of course, you can place them in a common assembly constrain them and then create a view of that but that’s not what the user wanted.

                The other common technique is to create each bend as a separate unfold/refold operation and convert the model to an iPart where you document each step of the process by suppressing fold/unfolds. You can then place multiple members on each drawing and the views will be aligned (should be because they share the same model..)

                The next code will get the X position of the first view and align the rest according to it. Views on drawing are positioned by Center so you need to get the Width of the view and divide it by 2 but it’s all in the code.

                You need to take care of the vertical Y position of the view and the code will align on X


Enjoy:

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oView As DrawingView

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet


' Process the rule, wrapping it in a transaction so the 
' entire process can be undone with a single undo operation. 
Dim trans As Transaction 
trans = ThisApplication.TransactionManager.StartTransaction( _ 
        oDrawDoc, "Alig Views")
        
        oFirstView = oSheet.DrawingViews.Item(1)
        
        'views are processed by center so we need to get center X and substract half view
        Dim XPos As Double
        XPos = oFirstView.Position.X - (oFirstView.Width/2)
        
        Dim oPoint2D As Inventor.Point2D
        
        'view position is XPos + half of each view
        For Each oView In oSheet.DrawingViews
            oPoint2D = ThisApplication.TransientGeometry.CreatePoint2D(XPos + (oView.Width/2),oView.Position.Y)
            oView.Position = oPoint2D
        Next
        
'finish the transaction
trans.End 

Later,

ADS.


photo credit: Simon & His Camera Reflected Wings On A Steel Butterfly - London City Office Life 2017 Version (license)