- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I find myself with large assemblies again and I have a plethora of user parameters (some of them are just for the purpose of being able to view the program for watching for errors) and I'm trying to categorize these parameters in order to make it much more manageable. However all there seems to be is the built in filters, but what would really be helpful would be the ability to create subcategories, like folders, to organize them by.
Is this at all possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Thomas,
Look in the API help for: Custom Parameter Groups, and you will find this code:
it might help you. (This is API only!)
Public Sub CreateParametersAndGroup()
' Create a new Part document.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
' Set a reference to the compdef.
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition
' Create a model parameter
Dim oModelParam As ModelParameter
Set oModelParam = oCompDef.Parameters.ModelParameters.AddByValue(2, kCentimeterLengthUnits)
' Create a reference parameter
Dim oReferenceParam As ReferenceParameter
Set oReferenceParam = oCompDef.Parameters.ReferenceParameters.AddByValue(4, kCentimeterLengthUnits)
' Create a user parameter
Dim oUserParam As UserParameter
Set oUserParam = oCompDef.Parameters.UserParameters.AddByValue("length", 6, kCentimeterLengthUnits)
' Create a new custom parameter group
Dim oCustomParamGroup As CustomParameterGroup
Set oCustomParamGroup = oCompDef.Parameters.CustomParameterGroups.Add("Custom Group", "CustomGroup1")
' Add the created parameters to this group
' Note that adding the parameters to the custom group
' does not remove it from the original group.
Call oCustomParamGroup.Add(oModelParam)
Call oCustomParamGroup.Add(oReferenceParam)
Call oCustomParamGroup.Add(oUserParam)
End Sub
Kudo's are also appreciated
Succes on your project, and have a nice day
Herm Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It looks a little over my head but I think I get it. I generally run these as not visual basic and this is running in an assembly. It looks like the rule shown was meant for a part document so I changed a little bit.
I ran it originally as straight vb and it didn't actually create anything that I could see so I tried modifying it a bit. This was a little test I ran to see if I could adapt it to accept pre existing Parameters, which sadly didn't work. Gave me the error "Object of type 'System.UInt32' cannot be converted to type 'Inventor.CommandTypesEnum'."
I've seen it before but that error seems to show up for a multitude of reasons. I did check the help area and while it mentions that you can create special parameter folders it doesn't say how oddly enough.
Thank you again
Sub Main()
Dim oAsmDoc as AssemblyDocument = ThisDoc.Document
Dim oAsmCompDef As ComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition
Dim oCustomParamGroup As CustomParameterGroup
oCustomParamGroup = oAsmCompDef.Parameters.CustomParameterGroups.Add("Custom Group", "Rafters")
oCustomParamGroup.Add("Rafters")
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Apologies, I made a bit of a mistake in that code though I'm still getting the same error. Here is the updated code.
Sub Main()
Dim oAsmDoc as AssemblyDocument = ThisDoc.Document
Dim oAsmCompDef As ComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition
Dim oCustomParamGroup As CustomParameterGroup
oCustomParamGroup = oAsmCompDef.Parameters.CustomParameterGroups.Add("Custom Group", "Rafters")
Dim oUserParam As UserParameter
oUserParam = ParaExist("Rafters")
oCustomParamGroup.Add(oUserParam)
End Sub
'The ParaExist function returns the parameter with the name passed to it.
Function ParaExist(sName)
Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document
Dim oCompDef As AssemblyComponentDefinition
oCompDef = oDoc.ComponentDefinition
For i = 1 To oCompDef.Parameters.Count
If oCompDef.Parameters(i).Name = sName
ParaExist = oCompDef.Parameter(i)
Exit For
End If
Next
End Function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
try this:
Sub Main() Dim oAsmDoc As AssemblyDocument = ThisDoc.Document Dim oAsmCompDef As AssemblyComponentDefinition = Nothing oAsmCompDef = oAsmDoc.ComponentDefinition Dim oCustomParamGroup As CustomParameterGroup = Nothing Try oCustomParamGroup = oAsmCompDef.Parameters.CustomParameterGroups.Add("Category name", "Category name") Catch ex As Exception 'it probably already exists oCustomParamGroup = oAsmCompDef.Parameters.CustomParameterGroups("Category name") End Try 'enter existing parameter name, and copy the line for more parameters Dim oExistingParam As Inventor.Parameter = GetExistingParam(oAsmDoc, "Length") 'add parameter oCustomParamGroup.Add(oExistingParam) Dim oExistingParam1 As Inventor.Parameter = GetExistingParam(oAsmDoc, "Width") 'add parameter oCustomParamGroup.Add(oExistingParam1) End Sub Private Function GetExistingParam(ByVal oAssydoc As Inventor.AssemblyDocument, oParamName As String) As Inventor.Parameter Dim oParam As Inventor.Parameter = Nothing For Each oParam In oAssydoc.ComponentDefinition.Parameters If oParam.Name = oParamName Then Return oParam End If Next Return Nothing End Function
put it all in one iLogic rule
Kudo's are also appreciated
Succes on your project, and have a nice day
Herm Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thank you! That does precisely what I wanted. I was a tad confused when I first tried it because it was still giving the error, but I realized it didn't have a catch for if it didn't find the parameter. If it didn't find it the function had a catch to just return nothing but then it tried to add nothing to the category. I may set up a catch later but for now the function works precisely as I wanted, thank you so much.