Issue trying to push properties to subcomponents

Issue trying to push properties to subcomponents

Anonymous
Not applicable
611 Views
3 Replies
Message 1 of 4

Issue trying to push properties to subcomponents

Anonymous
Not applicable

I am trying to have a form drive the overall assembly, which calls a rule to push all the input values to the sub assemblies and sub components. the aim is to only push values if the parameter exists in the sub component, so there aren't a bunch of unused values in each part. The below is not pushing values, and I do not know why.

 

Dim openDoc As Document
openDoc = Thisapplication.ActiveDocument
Dim oDoc As Inventor.Document
For Each oDoc In openDoc.AllReferencedDocuments
    If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
        Dim oPartDoc As PartDocument = TryCast(oDoc, PartDocument)
        Dim oCompdef As PartComponentDefinition = oPartDoc.ComponentDefinition
        Dim FNamePos As Long
        FNamePos = InStrRev(oPartDoc.FullFileName, "\", -1)
        Dim docFName As String
        docFName = Strings.Right(oPartDoc.FullFileName, Len(oPartDoc.FullFileName) - FNamePos)
        Dim oParam As Inventor.Parameter
        PropList = new string(){"DuctLength","DuctWallThickness","DuctWidth","DuctHeight","VesselCeilingToInletDuctFloor","InletDuctCeilingToPenthouseFloor","DisperserDiameterAtConeExit","SupportTubeOD","VesselDischargeDiameter","VesselCylindricalHeight","VesselCylindricalDiameter","OutletDuctDiameter"}
        For Each oParam In oPartDoc.ComponentDefinition.Parameters
            For Each oProp in PropList
                If oParam.Name = oProp Then
                    Parameter(oDoc,oProp)=Parameter(oProp)
                End If
            Next
        Next
        oPartDoc.Update()
    End If
Next
openDoc.Rebuild()

0 Likes
Accepted solutions (1)
612 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor

Hi,

 

The code you have written is very convoluted and has many extra lines that aren't needed, to being with.

 

What is your intent for moving these parameters? Are you PUSHING params from an assembly to all of the children parts? or are you PULLING the parameters from the parts to put into the assemblies? What is your intent after this, as they will in no way be linked by this.

 

As your code is written, you are looping only through parts ever, so there is nothing in the code to move parameters to assemblies or sub-assemblies.

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 4

Anonymous
Not applicable

The intent is that the master assembly with run this rule, and every part in its tree will have their parameters updated if they have one that matches the name of the master one. For example, every part with a parameter "DuctWidth" would have the value updated to what the master assembly has.

0 Likes
Message 4 of 4

MechMachineMan
Advisor
Advisor
Accepted solution
Here is code that works if all of your "Master Parameters" are actually User Parameters added to the top level. If nothing else, it'll maybe give you some ideas for how you can do things. in my opinion, it doesn't make sense to create a separate list of parameters to check that's hardcoded if they all already exist in the master assembly.

 

 

'ParamPush
'JRK -- 17 Aug 2016

'Purpose:
'Pushes param values to any sub document that is modifiable that has a param of the same name.


Sub Main()
	Dim oDoc As Document = ThisApplication.ActiveDocument
	
	For Each oParameter in oDoc.ComponentDefinition.Parameters.UserParameters
		oParamName = oParameter.Name
		oParamExp = oParameter.Expression
		'MsgBox(oParamName & vbLf & oParamExp)
			
		For Each oSubDoc in oDoc.AllReferencedDocuments
			If oSubDoc.IsModifiable = True
				Try
					oSubDoc.ComponentDefinition.Parameters(oParamName).Expression = oParamExp
					
					oStr = oStr & vbLf & oSubDoc.FullFileName & " -- " & oParamName
					'MsgBox(oParamName & " parameter found in:" & vbLf & oSubDoc.FullFileName)
				Catch
					'MsgBox(oParamName & " NOT FOUND in:" & vbLf & oSubDoc.FullFileName)
				End Try
				
			Else
				'Notify for non-modifiable files
				'MsgBox(oSubDoc.FullFileName & " is not Modifiable!")
			End If
		Next
	Next
	oDoc.Update
	MsgBox("Files changed:" & vbLf & oStr)
End Sub  

  


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type