ilogic coding Error - Please help!

ilogic coding Error - Please help!

Anonymous
Not applicable
427 Views
2 Replies
Message 1 of 3

ilogic coding Error - Please help!

Anonymous
Not applicable

I can't figure out what is wrong with this... I'm trying to open all drawings whose filename contains the project number. If i remove the "For each subOcc...." part it works fine. It seems to error out at the "oCurrentFilenameWithExtension = oOcc.ReferencedFileDescriptor.FullFileName" Line on the first sub occurence.

Error shown under my rule.

 

Also "ThisApplication.ActiveView.Fit" seems to be doing sweet FA

 

 

Class ThisRule
	
	Dim ComponentArray As New ArrayList

Sub Main

	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
	Dim oOcc_s As ComponentOccurrences = oCompDef.Occurrences

	'look at each occurrence in the assembly
	For Each oOcc As ComponentOccurrence In oOcc_s
			
		OpenDrawing(oOcc)
					
	Next
	
	MessageBox.Show("Please Check for Overlapping Dimensions, then Check in to Vault.", "All Drawings Have Been Generated")
	
End Sub

Sub OpenDrawing(oOcc)
	
	oCurrentFilenameWithExtension = oOcc.ReferencedFileDescriptor.FullFileName
	oCurrentFilenameWithoutExtension = oCurrentFilenameWithExtension.Substring(0, oCurrentFilenameWithExtension.Length - 4)
	
	If oOcc.Name.Contains(Project_Folder) And ComponentArray.Contains(oCurrentFilenameWithExtension) = False
			
		ComponentArray.Add(oCurrentFilenameWithExtension)

		Dim DrawingDoc As DrawingDocument = ThisApplication.Documents.Open(oCurrentFilenameWithoutExtension & ".dwg", True)

		ThisApplication.ActiveView.Fit
					
		DrawingDoc.Save

		For Each subOcc As ComponentOccurrence In oOcc.SubOccurrences
		
			OpenDrawing(subOcc)
		
		Next
		
	End If
	
End Sub

End Class

 

image.png

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

JamieVJohnson2
Collaborator
Collaborator
Accepted solution

break this line up into 2 operations

oCurrentFilenameWithExtension = oOcc.ReferencedFileDescriptor.FullFileName

rfd=oocc.ReferencedFileDescriptor

oCurrentFilenameWithExtension =rfd.FullFileName

you will find that rfd is nothing in some situation. use an if statement to clarify before continuing:

if rfd isnot nothing then

oCurrentFilenameWithExtension =rfd.FullFileName

'and all your other code...

end if

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks.

It must have been the weld bead that it was the culprit.

0 Likes