Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Filter parts in an idw

15 REPLIES 15
Reply
Message 1 of 16
ASchlaack
643 Views, 15 Replies

Filter parts in an idw

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?

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
15 REPLIES 15
Message 2 of 16
Mark.Lancaster
in reply to: ASchlaack

@ASchlaack

 

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.

Message 3 of 16
ASchlaack
in reply to: Mark.Lancaster

Thank you @Mark.Lancaster.

 

@Curtis_Waguespack I look forward to hearing what you have to say.

 

 

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
Message 4 of 16
mcgyvr
in reply to: ASchlaack

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... 

 

 

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 5 of 16
Cadmanto
in reply to: ASchlaack

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.

 

check.PNGIf this solved your issue please mark this posting "Accept as Solution".

Or if you like something that was said and it was helpful, Kudoskudos.PNG are appreciated. Thanks!!!! Smiley Very Happy

 

New EE Logo.PNG

Inventor.PNG     vault.PNG

Best Regards,
Scott McFadden
(Colossians 3:23-25)


Message 6 of 16
Curtis_Waguespack
in reply to: mcgyvr


@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. Smiley Tongue 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 Smiley Wink)

 

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

 

 

Message 7 of 16

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.

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
Message 8 of 16


@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. Smiley Embarassed

 

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

Message 9 of 16

Thank you very much!

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
Message 10 of 16

Hi ASchlaack,

  

So here's the vice grips. Don't put your eye out. Smiley Tongue  Actually this might be useful for our guys too.

 

Things to know:

  • I tested this only very quickly, so please do run this some test files before using and relying on it for production work.
  • The "bones" of this rule came from something else that looked for sheet metal parts and flat patterns and did stuff to the labels of those views. So if I missed a line or two of code that doesn't seem to belong, that's likely where they came from. Just comment them out and see if it impacts anything.

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

 

Message 11 of 16

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?

 

pg1.pngpg2.png

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
Message 12 of 16


@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.

 

  • It looks through the sheets and finds the parts list.
  • Then it goes through each line in the parts list and gets the full path and file name of that component
  • This it compares it to the path and file name of the component of each view.
  • If the path & names match, then a "flag" is set to say that it is found
  • If the flag does get tripped, then it prompts you to delete it.

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

 

 

Message 13 of 16


@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

Message 14 of 16

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!!

 

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
Message 15 of 16
MechMachineMan
in reply to: ASchlaack

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) 

--------------------------------------
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
Message 16 of 16

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report