Hello, I have a iLogic idea I want to use to help us inspect our iAssembly models during development. So I'm looking for help. If you just want to teach me, that's fine. If you want to write it and drop in a reply to save time, that's fine too.
One of the things we do frequently is activate every member and check them over for sick constraints and parts not constrained correctly... We do this so much that this can become a time suck b/c we build with iAssemblies often and they can sometimes get very big (lots of members but simple in scale). But it's very important even when you think you're done. B/c I've found sometimes a member needs to be activated once for positional views to accurately display in general... (I think you even have to activate those positions too but that besides the point atm). Anyways I got to thinking, what if we could use iLogic to speed up the process in some way? We already have iLogic that generates all members and bypasses having us hit the okay button every time it wants to save relationships to other files etc. This type of thing can pin someone in their seat for a very long time and was a boon for me and my teammates. So I'm hoping this is possible too.
So here's what I'm thinking.
Activate the iLogic rule
It searches for the first member and activates it.
Zooms to home
pauses for 5 seconds
display a message with quantity of sick constraints. (this can be on a timer to just move to next step)
Then activate the next member
rinse and repeat
Once the process reaches the end, the iLogic would then display which members had sick constraints and how many. The msg would have a print button for the user or a okay button.
I tried looking into this myself. I got as far as:
ChangeRow for changing member
thought it would need to maybe FindRow somehow to change to first member. Pulled it in and then got confused lol.
Inventor: Model States is not a replacement for iParts / iAssemblies. It does not have all the same features yet and does not communicate well with our large currently in use libraries. 😞 https://forums.autodesk.com/t5/inventor-ideas/model-state-support-tabulated-parts-list/idc-p/11360616
Just a quick search. Here is a rule for sick constraints. I am not too sure how each members constraints would be identified.
A quick rule to switch members.
'Set Manually where you want the loop to start StartRow = InputBox("Enter the Row Number you wish to Start the Loop", "iLogic", "1") EndRow = InputBox("Enter the Row Number you wish to Start the Loop", "iLogic", "") For iRow = StartRow To EndRow iPart.ChangeRow("", iRow) Next
So I may have cheated some would say... But I decided to do an experiment.
I used OpenAI API to write me some ilogic code. 😛
I have no idea what's it's doing but it's guesswork is far better than mine so far lol. Current error output when saving says: "Error on Line 8 : Type 'iAssemblyMembersCollection' is not defined."
Which tells me it just needs to know which command is the correct one. It's trained a Python normally so was hoping it could figure its way through this one...
So what do you guys think so far?
'Begin iLogic Code
'This code cycles through each member of the iAssembly and outputs a summary message log for which members have sick constraints
'Create variable to list all members
Dim iAssemblyMembers As iAssemblyMembersCollection
'Loop through each member
For Each Member In iAssemblyMembers.Members
'Check each member for sick constraints
If Member.HasSickConstraints() Then
'Output a summary msg log for which members have sick constraints
MsgBox("Member " & Member.Name & " has sick constraints")
End If
Next
'End iLogic Code
PS: The prompt I used to get this was: "Write iLogic code for Autodesk Inventor that always begins with the first member and cycles through each iAssembly member and outputs a summary msg log for which members have sick constraints. Add Comments to explain steps."
Inventor: Model States is not a replacement for iParts / iAssemblies. It does not have all the same features yet and does not communicate well with our large currently in use libraries. 😞 https://forums.autodesk.com/t5/inventor-ideas/model-state-support-tabulated-parts-list/idc-p/11360616
You can check the health status directly from the member see API help here , Curtis Post shows the HealthStatusEnum required to indicate an error.
So it looks like you wont be able to check the members health in the factory but you can check the assembly definitions constraints health. Here is the working rule.
Dim AssyDoc As AssemblyDocument = ThisDoc.Document
Dim AssyDef As AssemblyComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim iAssyFactory As iAssemblyFactory = AssyDef.iAssemblyFactory
Dim iAssyRows As iAssemblyTableRows = iAssyfactory.TableRows
Dim iNumRows As Integer = iAssyFactory.TableRows.Count
Dim MemberNames As New List (Of String)
Dim iRow As Integer
Dim i As Integer = 0
'Reset the factory to row 1
iAssyFactory.DefaultRow = iAssyRows.Item(1)
For iRow = 1 To iNumRows
iAssyFactory.DefaultRow = iAssyRows.Item(iRow)
For Each oConstraint In AssyDef.Constraints
If oConstraint.HealthStatus <> HealthStatusEnum.kUpToDateHealth And _
oConstraint.HealthStatus <> HealthStatusEnum.kSuppressedHealth Then
'oConstraint.Delete
MemberNames.Add(iAssyRows.Item(iRow).MemberName)
'Logger.Info("Constraints Error Found on Row#: " & iRow)
i = i + 1
End If
Next
Next
MessageBox.Show(" A total of " & i & " constraints errors found.", "iLogic")
d0 = InputListBox("Prompt", MemberNames, d0, Title := " Constraints: Error Members", ListName := "List")
Can't find what you're looking for? Ask the community or share your knowledge.