I don't know if there's a feature I don't know about or if there's ilogic code somebody has to do this already. But what I'd like to be able to do is in a large idw, if someone edits the model and deletes a part and you don't know which part, it's a pain to search though all the part drawing views and find the part details for the now deleted part. Is there a feature or code that can search and find/delete any parts that are in a drawing based off of the BOM or some other filter source?
Out of the box there's nothing but I tag @Curtis_Waguespack to see if he has any snippet/code that will do this for you.
Mark Lancaster
& Autodesk Services MarketPlace Provider
Autodesk Inventor Certified Professional & not an Autodesk Employee
Likes is much appreciated if the information I have shared is helpful to you and/or others
Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.
Thank you @Mark.Lancaster.
@Curtis_Waguespack I look forward to hearing what you have to say.
I feel sorry for you..
Shouldn't the person that deletes the part also be responsible for ensuring all documentation is updated?
Don't you have a quality procedure where changes are recorded and you aren't in a "who deleted this and why did someone make the part" issue..
It also sucks that you work somewhere that this is even an issue.. So glad I follow the 1 part..1 drawing principle..
And also sucks you don't have an ERP system as if you did this wouldn't even be an issue either..
Sorry.. I know I'm no help.. But I HIGHLY suggest you fix your processes/training,etc.. instead of incorporating more complexity...
Aaron,
I feel bad for you as well. Clearly you are not using Vault or there would be a history of this drawing. Where you could see not only who did this, but when to be able to track and maybe restore back to when this happened so you can do this the responsible way.
Best of luck with this.
If this solved your issue please mark this posting "Accept as Solution".
Or if you like something that was said and it was helpful, Kudos are appreciated. Thanks!!!!
@mcgyvr wrote:
... fix your processes/training,etc.. instead of incorporating more complexity...
Hi ASchlaack,
I looked at this thread a couple of hours ago when Mark.Lancaster tagged me, and my spidey sense went off concerning process as well. I would want the person doing the deleting to be responsible for cleaning up the drawings.
However, I like a little automation to help me when I'm they guy that is doing the deleting and the guy doing the cleaning up. I understand that "fabrication" style drawings are simply never going to be 1 part = 1 drawing, and it can be time consuming to hunt through the sheets for minor errors and omission manually.
On Process
Process is the vehicle you ride in to deliver success. Workarounds are the blocks upon which you prop up that vehicle when you're missing a wheel, and the duct tape and trash bags you use to cover the missing windows, and the rusty vice grips we use to replace the window crank (suddenly I miss the old truck I had when I was 16 )
A workaround from time to time to keep us moving is not an issue in my mind, but sometimes workarounds beget more workarounds, and too many workarounds leave us to sit in the drive way making "vroom-vroom" noises, fooling ourselves into thinking we're going somewhere.
"... find the part details for the now deleted part "
iLogic here might just be rusty vice grips for a window crank. Do you just want to catch all the views that have missing references? I think that's doable. Is there more to it? Are you looking to find orphaned dimensions, etc.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
I mean to dumb it down so I can explain...
I have my assembly with 5 ipts in in.
I have my first page of the drawing showing the weldment, how to assemble it... ect...
On the following page I have my 5 parts each detailed out with flat patterns and all of that good stuff.
------------
I now go back to my assembly and decide to delete part #3.
Now rather than going to my detail page and having to hunt through all 5 parts details I'd like inventor to have a "smart" way of being able to look at my assembly and say "Part#3 is no longer in this assembly, I should delete its views and flat pattern".
-----------
Does that make sense?
And as for everyone else's comments, having something able to do this seems that it would be helpful even if I was the one who removed the part and all of this was done the "correct" way. It would save time by not having to look for where the part is detailed. But I mean, what do I know.
@ASchlaack wrote:
Is there a feature or code that can search and find/delete any parts that are in a drawing based off of the BOM or some other filter source?
Hi ASchlaack,
Okay, I got it now, It was clear in your first post, once I looked at it again.
The views and dimensions are healthy, because they reference the part files directly, But the assembly no longer references those parts. You want to find those views.
I have something in place that combs the parts list and checks it against the drawing views. So I think I can help with this. I'll try to post back later today.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Thank you very much!
Hi ASchlaack,
So here's the vice grips. Don't put your eye out. Actually this might be useful for our guys too.
Things to know:
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Sub Main oMessage = "Files in drawing not in the parts list:" '____Create text file oLogPath = "C:\TEMP\" & ThisDoc.FileName(False) & ".txt" oWrite = System.IO.File.CreateText(oLogPath ) oWrite.WriteLine(oMessage) oWrite.WriteLine("__________________________________________") oWrite.WriteLine("__________________________________________") oWrite.Close() 'Set a reference To the drawing document.' 'This assumes a drawing document Is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oSheets As Sheets Dim Sheet As Inventor.Sheet Dim oViews As DrawingViews Dim oView As DrawingView oPListFound = False 'set flag default For Each oSheet In oDrawDoc.Sheets If oSheet.PartsLists.Count > 0 Then oPListFound = True End If Next If oPListFound = False Then Return 'exit rule if no parts list For Each oSheet In oDrawDoc.Sheets 'For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews 'Get the full filename Of the view model Dim oModelFileName As String oModelFileName = _ oView.ReferencedDocumentDescriptor.ReferencedDocument.FullFileName Dim oPartList As PartsList 'try and get the parts list from the table of this sheet Try oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1) Catch 'on error try and search all sheets for first found partslist 'iterate trough each sheet Dim i As Long For i = 1 To oDrawDoc.Sheets.Count If oDrawDoc.Sheets.Item(i).PartsLists.Count > 0 Then Exit For Next oPartList = oDrawDoc.Sheets.Item(i).PartsLists.Item(1) End Try oPartListRefDoc = _ oPartList.ReferencedDocumentDescriptor.FullDocumentName ' Iterate through the contents of the parts list. Dim j As Long For j = 1 To oPartList.PartsListRows.Count ' Get the current row. Dim oRow As PartsListRow oRow = oPartList.PartsListRows.Item(j) 'count number of files the row references oCount = oRow.ReferencedFiles.count 'get filename of model in row Dim oRowFileName As String k = 1 Do Until k = oCount+1 'get full file name Try oRowFileName = oRow.ReferencedFiles.Item(k).FullFileName Catch oRowFileName = "" 'catch error End Try oFound = False 'sets default value 'compare the filenames If oRowFileName = "" Then oFound = True 'Performs a text comparison, 'based On a Case-insensitive text sort order Else If StrComp(oModelFileName, oRowFileName, _ CompareMethod.Text)=0 Then oFound = True Else If StrComp(oModelFileName,oPartListRefDoc, _ CompareMethod.Text)=0 Then oFound = True End If k = k + 1 Loop Next If oFound = False Then oMessage = oSheet.Name & " : " _ & oView.Name & " : " _ & oModelFileName oNotFoundCounter = oNotFoundCounter + 1 '____Open and append text file with next line Dim oAppend As System.IO.StreamWriter oFile = oLogPath oAppend = IO.File.AppendText(oFile) oAppend.WriteLine(oMessage) oAppend.Flush() oAppend.Close() 'get user input RUsure = MessageBox.Show ( _ "Do you want to delete this view? " & vbLf & oMessage, _ "Component not found in parts list",MessageBoxButtons.YesNo) If RUsure = vbYes Then oView.Delete End If End If Next Next If oNotFoundCounter > 1 Then ThisDoc.Launch(oLogPath) Else MessageBox.Show("All views match files in the parts list.", "iLogic") End If End Sub
Thank you! That seems to be getting close, is there somewhere in the code I have to reference the bill?
On the first page I have the bill that's linked to the two assembly views on that page.
Then on the second page there are three parts with two views that are in the assembly, and the one piece that isn't in the assembly that I highlighted in red.
When I run the rule though it tries to delete all the views on the second page. Am I missing something?
@ASchlaack wrote:
Thank you! That seems to be getting close, is there somewhere in the code I have to reference the bill?
On the first page I have the bill that's linked to the two assembly views on that page.
Then on the second page there are three parts with two views that are in the assembly, and the one piece that isn't in the assembly that I highlighted in red.
When I run the rule though it tries to delete all the views on the second page. Am I missing something?
Hi ASchlaack,
No, you shouldn't have to change anything.
I'll try to do a bit more testing later, but if you can think of anything that would make that workflow fail with your files let me know.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
@Curtis_Waguespack wrote:
@ASchlaack wrote:
Thank you! That seems to be getting close, is there somewhere in the code I have to reference the bill?
On the first page I have the bill that's linked to the two assembly views on that page.
Then on the second page there are three parts with two views that are in the assembly, and the one piece that isn't in the assembly that I highlighted in red.
When I run the rule though it tries to delete all the views on the second page. Am I missing something?
correction:
- If the path & names match, then a "flag" is set to say that it is found
- If the flag does NOT get tripped, then it prompts you to delete it.
Hi ASchlaack,
I just ran this a couple of more times and I get the same results I was getting before.
Are the components on the second sheet that you expect it not to want to delete, in the parts list?
Note too that I noticed a typo in my last post.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Sorry, I haven't gotten a chance to reply but I just can't seem to get it to work. Could you post or send me a sample part I could check out and hopefully be able to solve my issue. Because I really am assuming that my issue is just something I'm missing or setting up my pages different from how you do it.
Thanks!!
I could be wrong, but if I were too look somewhere, it would be in this loop as the behaviour/rest of the code indicates that it may be flagging every view for deletion.:
Do Until k = oCount+1 'get full file name Try oRowFileName = oRow.ReferencedFiles.Item(k).FullFileName Catch oRowFileName = "" 'catch error End Try oFound = False 'sets default value 'compare the filenames If oRowFileName = "" Then oFound = True 'Performs a text comparison, 'based On a Case-insensitive text sort order Else If StrComp(oModelFileName, oRowFileName, _ CompareMethod.Text)=0 Then oFound = True Else If StrComp(oModelFileName,oPartListRefDoc, _ CompareMethod.Text)=0 Then oFound = True End If k = k + 1 Loop
Could check by adding this AFTER "Loop" and seeing what the result are.
MsgBox("View: " & oView.Name & vblf & "Found: " & oFound)
Hi ASchlaack,
Give this version a try and let me know if it's still not correct.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Sub Main oMessage = "Files in drawing not in the parts list:" '____Create text file oLogPath = "C:\TEMP\" & ThisDoc.FileName(False) & ".txt" oWrite = System.IO.File.CreateText(oLogPath ) oWrite.WriteLine(oMessage) oWrite.WriteLine("__________________________________________") oWrite.WriteLine("__________________________________________") oWrite.Close() 'Set a reference To the drawing document.' 'This assumes a drawing document Is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oSheets As Sheets Dim Sheet As Inventor.Sheet Dim oViews As DrawingViews Dim oView As DrawingView oPListFound = False 'set flag default For Each oSheet In oDrawDoc.Sheets If oSheet.PartsLists.Count > 0 Then oPListFound = True End If Next If oPListFound = False Then Return 'exit rule if no parts list For Each oSheet In oDrawDoc.Sheets 'For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews 'sets default value oFound = 0 'Get the full filename Of the view model Dim oModelFileName As String oModelFileName = _ oView.ReferencedDocumentDescriptor.ReferencedDocument.FullFileName Dim oPartList As PartsList 'try and get the parts list from the table of this sheet Try oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1) Catch 'on error try and search all sheets for first found partslist 'iterate trough each sheet Dim i As Long For i = 1 To oDrawDoc.Sheets.Count If oDrawDoc.Sheets.Item(i).PartsLists.Count > 0 Then Exit For Next oPartList = oDrawDoc.Sheets.Item(i).PartsLists.Item(1) End Try oPartListRefDoc = _ oPartList.ReferencedDocumentDescriptor.FullDocumentName ' Iterate through the contents of the parts list. Dim j As Long For j = 1 To oPartList.PartsListRows.Count ' Get the current row. Dim oRow As PartsListRow oRow = oPartList.PartsListRows.Item(j) 'count number of files the row references oCount = oRow.ReferencedFiles.count 'get filename of model in row Dim oRowFileName As String k = 1 Do Until k = oCount+1 'get full file name Try oRowFileName = oRow.ReferencedFiles.Item(k).FullFileName Catch oRowFileName = "" 'catch error End Try 'skip when varaible is empty If oRowFileName = "" Then oFound = 1 Continue For End If 'skip when view of top level assembly If StrComp(oModelFileName,oPartListRefDoc, _ CompareMethod.Text)=0 Then oFound = 1 Continue For End If 'compare the filenames 'Performs a text comparison, 'based On a Case-insensitive text sort order If StrComp(oModelFileName, oRowFileName, _ CompareMethod.Text)=0 Then oFound = oFound +1 End If k = k + 1 Loop Next If oFound = 0 Then oMessage = oSheet.Name & " : " _ & oView.Name & " : " _ & oModelFileName oNotFoundCounter = oNotFoundCounter + 1 '____Open and append text file with next line Dim oAppend As System.IO.StreamWriter oFile = oLogPath oAppend = IO.File.AppendText(oFile) oAppend.WriteLine(oMessage) oAppend.Flush() oAppend.Close() 'get user input RUsure = MessageBox.Show ( _ "Do you want to delete this view? " & vbLf & oMessage, _ "Component not found in parts list",MessageBoxButtons.YesNo) If RUsure = vbYes Then oView.Delete End If End If Next Next If oNotFoundCounter > 0 Then ThisDoc.Launch(oLogPath) Else MessageBox.Show("All views match files in the parts list.", "iLogic") End If End Sub