Hi there,
I have created a model using solids in a part file.
I have then created an assembly file from this using the 'Make Components' option.
From the resulting assembly i would like to insert an iLogic form which lets the user change parameters in the solids model.
Is there anyway to do this?
I can't use the MakePath option as the solid model is not in the assembly ( i do not want it in the assembly).
Could I use some API code to achieve my goal?
thanks,
John
Solved! Go to Solution.
Solved by cwhetten. Go to Solution.
Can you use the link parameter tool to add the assembly's parameters as reference parameters inside the multi-body solid part?
I thought that might be the case. You could try passing the parameters through a "dummy part". This would be a geometeryless empty ipt file with the needed parameters in it. You can then place this into the assembly (use the reference bom structure to keep it off your BOM) and use iLogic to pass the parameters to this "dummy part". You can then use the link parameters tool to link your multi-body solid to the "dummy part".
This isn't the most elegant solution, but it does work. Although, I've never tried it with multi-bodies.
What version of Inventor are you using. What you want to do is trivially easy with iLogic. Have you ever used iLogic?
-cwhetten
I am using 2012.
I have not managed to achieve changing the parameter with iLogic as the part with the parameters is not in the assembly so i cannot use the 'Make Path' function.
I was thinking I might need some code which opens the part, updates the parameters, then closes it.
I have not placed the solids model in the assembly as it will often contain errors (the red cross appears as some 'Cut' features are having no effect). I do not want my assembly file to dispay the red cross as this may cause concern for the users.
thanks,
John
@johnster100 wrote:...the part with the parameters is not in the assembly...
This complicates things quite a bit. But, it's still possible.
@johnster100 wrote:I was thinking I might need some code which opens the part, updates the parameters, then closes it.
This is the same conclusion I came to. See the attached assembly for an example of how to do this. Also, for others' benefit, here is the code:
------------------------------------
'Get the component that is derived from the master part. Change the name of "_ThePart" to match one of your components
oPartDoc = Component.InventorComponent("_ThePart")
'Get the full path and name of the master part
oDerivedSourcePartFullName = oPartDoc.Definition.Document.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).ReferencedDocumentDescriptor.FullDocumentName
'Open the master part in memory so that the parameters will be accessible
oDerivedSourcePart = ThisApplication.Documents.Open(oDerivedSourcePartFullName, False)
'Set the values of d0 and d1 in the master part. This value is expected in database units, cm,
'so we divide by 1 cm to tell Inventor to convert it to cm, so it will handle the units properly.
'Change the names of "d0" and "d1", and "Width" and "Height" to match your parameter names.
oDerivedSourcePart.ComponentDefinition.Parameters.Item("d0").Value = Width/1 cm
oDerivedSourcePart.ComponentDefinition.Parameters.Item("d1").Value = Height/1 cm
'Get the set of all open, visible documents
allVisibleDocs = ThisApplication.Documents.VisibleDocuments
'Create a test variable and set its default value
docIsVisible = False
'Test if the master part is in the set of open, visible documents. If so, sets the test variable to True
For Each oDoc In allVisibleDocs
If oDerivedSourcePart.InternalName = oDoc.InternalName Then
docIsVisible = True
End If
Next
'If the document is open and visible, then leave it open. If it is not, then close the document.
If docIsVisible Then
'do nothing
Else
oDerivedSourcePart.Close
End If
iLogicVb.UpdateWhenDone = True
------------------------------------
The only way I could get this to work is to get the filename and path of the master part and then open it in memory. It seems to me that there is probably a better way to do this, but I can't figure it out. If Curtis sees this thread, maybe he can offer some advice on a better way to write the code.
But, it seems to work. If you change the value of the Width or Height parameters in the assembly, the derived part gets updated. This would also work if you have many parts in your assembly that are all derived from the same master part (which is usually the case with multi-solid modeling). All you need to change is the name of the component that it gets (you only need to get one component, not every component that is derived), and the names of your parameters. You can also add more parameters as needed.
-cwhetten
Please click "Accept as Solution" if this response answers your question.