Showing posts with label iProperties. Show all posts
Showing posts with label iProperties. Show all posts

Wednesday, June 11, 2014

Placeholders on iLogic Forms

I recently had a case where a colleague was setting a custom iProperty (Program Number) to either the file name or a custom field and he was using a boolean parameter to determine which of these to use to set it.

Here is his original code:
'********************************************************
'Set Program Name

If Set_Prog_Name = True Then
    iProperties.Value("Custom", "Program Number") = ThisDoc.FileName(False) 'without extension
Else
    iProperties.Value("Custom", "Program Number") = ""
End If

'********************************************************
We can see from the original code that when Set_Prog_Name = False that the Program Number will be set to <blank>.  He needed a way to allow the end user to enter a value in the Program Number field.

My immediate response wast to set up an input box but he preferred to not have an additional dialog box.

The end solution was one to add a placeholder iProperty, which I called Program_Name_Temp, on the form in place of the original Program Number and set the value of the Program Name iProperty equal to the placeholder when Set_Prog_Name = False.  As an additional bonus, I added a controlling parameter for Program_Name_Temp which is called Set_Prog_Name_Controls.

'********************************************************
'Set Program Name

If Set_Prog_Name = True Then
    Set_Prog_Name_Controls = False
    iProperties.Value("Custom", "UserInfo2") = ThisDoc.FileName(False) 'without extension
    Program_Name_Temp = iProperties.Value("Custom", "Program Name")
Else
    Set_Prog_Name_Controls = True
    iProperties.Value("Custom", "Program Name") = Program_Name_Temp
End If

'********************************************************

I hope this helps you on a future or current project.

Randy

"Even if you're on the right track, you'll get run over if you just sit there ." - Will Rogers

Monday, March 17, 2014

An iProp for the unique items

A request came in for a modification on the 'iProp For Everyone' post.  The post requested for the code to ignore additional instances of an occurrence.

One way of doing this is by using the AllReferencedDocuments.  There is only reference per file so this approach will take care of the unique item issue.  This differs from the original alternative approach I took where I looked at the ComponentOccurrences.

'   Get the active assembly. 
    Dim oAsmDoc As AssemblyDocument 
    oAsmDoc = ThisApplication.ActiveDocument
    
'   Get the PropertySets object. 
    Dim oPropSets As PropertySets 
    Dim oPropSet As PropertySet 
    
'   Iterate thru each referenced document
    Dim oDoc As Document 
    For Each oDoc In oAsmDoc.AllReferencedDocuments 
        oPropSets = oDoc.PropertySets
        oPropSet = oPropSets.Item("Inventor User Defined Properties")     

        Try                                                
        '    Push the required iProperties down to the documents
            oSONumiProp = oPropSet.Item("SO_Number")
            oSONumiProp.Value = Sales_Order_Number
            oCompanyiProp = oPropSet.Item("Company")
            oCompanyiProp.Value = Customer_Name
            oProjectiProp = oPropSet.Item("Project Description")
            oProjectiProp.Value = Project_Description
        Catch
        '    Do not raise or display an error.
        End Try
    Next 


Hopefully you see some benefit in the above solution.  Leave me a comment and let me know.

Randy

"The mind is everything. What you think you become." - Buddha

Wednesday, October 23, 2013

...An iProp For Everyone!

In my last post, I showed one solution to a common task of using assembly level parameters to set iProperties of part files in your assembly using an Array and a For Next Loop.  Using that solution, we specified each component that we wanted to push the iProperties to.

In this post, I'd like to discuss another solution that will push iProperties down to all components in your assembly, even those inside of sub-assemblies.


Sub Main
        Dim oAsmDoc As AssemblyDocument 
        oAsmDoc = ThisApplication.ActiveDocument 

    '    Call the function that does the recursion. 
        Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences, 1)
End Sub 

Private Sub TraverseAssembly(Occurrences As ComponentOccurrences, Level As Integer) 
    '    Iterate through all of the occurrences in this assembly.  Level 1 components. 
    
        Dim oOcc As ComponentOccurrence 
        For Each oOcc In Occurrences 
        
        '    Get the selected item document occurrence name
            Dim oBrowserNode As String
            oBrowserNode = oOcc.Name
    
                Try                                                
                    '    Push the required iProperties down to the occurrences
                        iProperties.Value(oBrowserNode, "Custom", "SO_Number") = Sales_Order_Number
                        iProperties.Value(oBrowserNode, "Custom", "Company") = Customer_Name
                        iProperties.Value(oBrowserNode, "Project", "Project") = Project_Description
        
                Catch
                    '    Do not raise or display an error.
                
                End Try
        
            '    Check to see if this occurrence represents a subassembly 
            '    and recursively call this function to traverse through it. 
                If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
                    
                    Call TraverseAssembly(oOcc.SubOccurrences, Level + 1) 
                    
                End If 
        Next 
End Sub

The above code will go iterate through each occurrence in your assembly and set the required iProperties.  If the occurrence is a sub-assembly, it will also iterate through each component inside of that sub-assembly.

Hopefully you see some benefit in the above solution.  Leave me a comment and let me know.

Randy

"The only way to do great work is to love what you do." - Steve Jobs

Wednesday, February 29, 2012

Driving Standards–Part 1



iLogic External Rules and Forms are tailor-made to help you control the more universal elements behind your design process. In this series of articles we’ll take a look at how we can leverage this technology to help you gain more control of your design data.
This sample will illustrate a technique for prompting a user to identify a designation or identifier that we would like to be entered as an iProperty in the “Title” area of the iProperty “Summary” Tab.

Friday, December 30, 2011

Controlling Parameter and iProperty Values

We can use iLogic to help us enforce standards and other values I like to refer to as “tribal knowledge”. Having customized code trap errors in design to help prevent (or at least flag) those “freelance” design changes is a powerful and effective way of managing the expense of change at the earliest stages of the process and turning your 3D models into true knowledge assets.


In this example we have established the proper number of ribs needed for this model based on the material of the part and are enforcing them with a rule. We are also enforcing the overall size limits of the model so that the Length must be between 4” and 10” and the Width must fall between 2” and 3”. We’ll also have a rule that will enforce the increment value of Length and Width.