Can anyone point me in the right direction as to how to change the G_L parameter from decimal to fraction (1/16)? I've attached some screnshots.
Solved! Go to Solution.
Solved by pierre.masson. Go to Solution.
Hello Crepps
By going in the part itself, clicking in the parameters, Customer Parameter G_L.
If you right click in the value field, Custom Parameter properties. Then you can set the value to fractional.
Going back in the assembly, if you go in the BOM, add custom Iproperty G_L
Is it fine like this ? Was it helpful ?
What if I have a frame generated part that has 100 members in it. Is there a quicker way of changing G_L to a fraction so that I don't have to go into all 100 parts to change the custom properties?
You can make a custom family in the Content Center, where you've replaced the family part template with one that has the property set to fractional. I have that set up in mine for all of the structural members I commonly use.
However, that doesn't help you with a frame that's already built. It would only prevent the problem you're having now from getting you again. I don't know of a way to do it quickly after the fact.
Hi,
Sorry for the late reply. I wrote a piece of Code to automate the Unit Change in the BOM parameter.
This is based on Bob Van der Donk's Code.
We scan all the occurences of the Assembly, if it is a Frame member, we change the unit of G_L to in and change the precision to 1/8. I had to us the precision change to force the switch to fractional. You can easily use another precision value as long as it is a fractional one.
Please test the code before pushing this to production.
Please Kudo if you like so others will see it.
Option Explicit
Public Sub Correct_G_L_parameter()
' Set reference to active document.
' This assumes the active document is an assembly
Dim odoc As Inventor.AssemblyDocument
Set odoc = ThisApplication.ActiveDocument
' Get assembly component definition
Dim oCompDef As Inventor.ComponentDefinition
Set oCompDef = odoc.ComponentDefinition
Dim sMsg As String
Dim iLeafNodes As Long
Dim iSubAssemblies As Long
' Get all occurrences from component definition for Assembly document
Dim oCompOcc As ComponentOccurrence
For Each oCompOcc In oCompDef.Occurrences
' Check if it's child occurrence (leaf node)
If oCompOcc.SubOccurrences.Count = 0 Then
iLeafNodes = iLeafNodes + 1
Call Assign_ref_to_G_L(oCompOcc)
Else
iSubAssemblies = iSubAssemblies + 1
Call processAllSubOcc(oCompOcc, _
sMsg, _
iLeafNodes, _
iSubAssemblies) ' subassembly
End If
Next
odoc.Update
'Save the assembly
'odoc.Save
End Sub
' This function is called for processing sub assembly. It is called recursively
' to iterate through the entire assembly tree.
Private Sub processAllSubOcc(ByVal oCompOcc As ComponentOccurrence, _
ByRef sMsg As String, _
ByRef iLeafNodes As Long, _
ByRef iSubAssemblies As Long)
Dim oSubCompOcc As ComponentOccurrence
For Each oSubCompOcc In oCompOcc.SubOccurrences
' Check if it's child occurrence (leaf node)
If oSubCompOcc.SubOccurrences.Count = 0 Then
iLeafNodes = iLeafNodes + 1
Call Assign_ref_to_G_L(oSubCompOcc)
Else
sMsg = sMsg + oSubCompOcc.Name + vbCr
iSubAssemblies = iSubAssemblies + 1
Call processAllSubOcc(oSubCompOcc, _
sMsg, _
iLeafNodes, _
iSubAssemblies)
End If
Next
End Sub
Private Sub Assign_ref_to_G_L(ByRef oCompOcc As ComponentOccurrence)
Dim odoc As Object
Dim oparams As Parameters
Dim oparam As Parameter
Set odoc = oCompOcc.Definition.Document
Set oparams = odoc.ComponentDefinition.Parameters
'Check if it is a part document and if it is not read-only and if it is a framegenerator beam
If (TypeOf odoc Is PartDocument) And (odoc.IsModifiable) And (odoc.DocumentInterests.hasinterest("{AC211AE0-A7A5-4589-916D-81C529DA6D17}")) Then
For Each oparam In oparams.UserParameters
' Find the G_L parameter and make sure at least a reference parameter exists in the beam
If oparam.Name = "G_L" And oparams.ReferenceParameters.Count > 0 Then
If oparam.CustomPropertyFormat.Units <> "in" Then
oparam.CustomPropertyFormat.Units = "in"
End If
If oparam.CustomPropertyFormat.Precision <> 85517 Then
oparam.CustomPropertyFormat.Precision = 85517
End If
End If
Next oparam
End If
End Sub
Hi,
My self also facing same problem,
I do not need unit string appear in BOM. also how to load listed code in inventor...
Hi John,
How to make a custom family in the Content Center?
I am also facing same problem...
Please Help...
Hello Pierre Masson,
Thanks for useful information, but,
What about already generated frame, by going 100 or more parts to change the same it is time consuming job.
is there any other idea that can help us change the parameters...
Can you put all your frame generator parts in C:\Temp folder. Then run this code that will open all IPTs from this folder and make the modification.
This code might require some slights adjustments.
Sub ChangeBOMUnit()
On Error GoTo Getout
Dim opart As PartDocument
ThisApplication.SilentOperation = True
Dim colFiles As New Collection
RecursiveDir colFiles, "C:\Temp", "*.ipt", True
Dim vFile As Variant
For Each vFile In colFiles
Set odrawing = ThisApplication.Documents.Open(vFile)
Call Assign_ref_to_G_L(opart)
opart.Save
opart.Close
Next vFile
Getout:
ThisApplication.SilentOperation = False
End Sub
Public Function RecursiveDir(colFiles As Collection, _
strFolder As String, _
strFileSpec As String, _
bIncludeSubfolders As Boolean)
Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant
'Add files in strFolder matching strFileSpec to colFiles
strFolder = TrailingSlash(strFolder)
strTemp = Dir(strFolder & strFileSpec)
Do While strTemp <> vbNullString
colFiles.Add strFolder & strTemp
strTemp = Dir
Loop
If bIncludeSubfolders Then
'Fill colFolders with list of subdirectories of strFolder
strTemp = Dir(strFolder, vbDirectory)
Do While strTemp <> vbNullString
If (strTemp <> ".") And (strTemp <> "..") And (strTemp <> "OldVersions") Then
If (GetAttr(strFolder & strTemp) And vbDirectory) <> 0 Then
colFolders.Add strTemp
End If
End If
strTemp = Dir
Loop
'Call RecursiveDir for each subfolder in colFolders
For Each vFolderName In colFolders
Call RecursiveDir(colFiles, strFolder & vFolderName, strFileSpec, True)
Next vFolderName
End If
End Function
Public Function TrailingSlash(strFolder As String) As String
If Len(strFolder) > 0 Then
If Right(strFolder, 1) = "\" Then
TrailingSlash = strFolder
Else
TrailingSlash = strFolder & "\"
End If
End If
End Function
Private Sub Assign_ref_to_G_L(ByRef odoc As Partdocument)
Dim oparams As Parameters
Dim oparam As Parameter
Set oparams = odoc.ComponentDefinition.Parameters
'Check if it is a part document and if it is not read-only and if it is a framegenerator beam
If (TypeOf odoc Is PartDocument) And (odoc.IsModifiable) And (odoc.DocumentInterests.hasinterest("{AC211AE0-A7A5-4589-916D-81C529DA6D17}")) Then
For Each oparam In oparams.UserParameters
' Find the G_L parameter and make sure at least a reference parameter exists in the beam
If oparam.Name = "G_L" And oparams.ReferenceParameters.Count > 0 Then
If oparam.CustomPropertyFormat.Units <> "in" Then
oparam.CustomPropertyFormat.Units = "in"
End If
If oparam.CustomPropertyFormat.Precision <> 85517 Then
oparam.CustomPropertyFormat.Precision = 85517
End If
End If
Next oparam
End If
End Sub
End Sub