Help me find this Object Reference error

Help me find this Object Reference error

Anonymous
Not applicable
428 Views
1 Reply
Message 1 of 2

Help me find this Object Reference error

Anonymous
Not applicable

I've tried reading all the related posts on here regarding the 'Object Reference Not Set' error but nothing seems to be working and I'm running out of ideas. I don't get any information regarding where this error is occuring and having tried the MsgBox("Here") method I've found that the code fails during the bold section. Any help would be much appreciated.

 

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oTB1 As TitleBlock
Dim titleDef As TitleBlockDefinition
Dim oPrompt
Dim title As String
Dim titleVal As String
Dim oCurrentSheet
Dim oTitleBlock As TitleBlock
Dim oTextBoxes As TextBoxes
Dim oTextBox As TextBox
Dim oPromptEntry
Dim oPtDoc As String




oDoc = ThisApplication.ActiveDocument
oCurrentSheet = oDoc.ActiveSheet.Name
oSheet = oDoc.Activesheet
oTB1 = oSheet.TitleBlock
titleDef = oTB1.Definition

'For Each defText As TextBox In titleDef.Sketch.TextBoxes
'	If defText.Text = "<TITLE>" Then
'		oPrompt = defText
'		Exit For
'	End If
'Next

'title = oTB1.GetResultText(oPrompt)
'iProperties.Value("Summary", "Title") = title
	MsgBox("Here")

'	For Each oSheet In oDoc.Sheets	
'		oDoc.Sheets.Item(1).Activate

'			oTitleBlock = oSheet.TitleBlock
'			oTextBoxes = oTitleBlock.Definition.Sketch.TextBoxes
'			For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
'				Select oTextBox.Text
'					Case "<TITLE>"
'						oPromptEntry = oTitleBlock.GetResultText(oTextBox)
'						iProperties.Value("Summary", "Title") = oPromptEntry
'				End Select
'			Next
'	Next



'	oDoc.Sheets.Item(oCurrentSheet).activate

'	ddoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
'	iProperties.Value(ddoc, "Summary", "Title") = iProperties.Value("Summary", "Title")

oPtDoc = oDoc.ActiveSheet.DrawingViews(1).Name


modelName = IO.Path.GetFileName(ActiveSheet.View(oPtDoc).ModelDocument.FullFileName)
iProperties.Value(modelName, "Summary", "Title") = "Test"

iLogicVb.UpdateWhenDone = True


Logger.Debug("Title: " & title)

iLogicForm.Show("Save Drawing")

If saved = True Then
	ThisDoc.Document.saveasinventordwg("C:\VaultWS\Designs\Umbilical\Workshop Equipment\HHAM\Closing Die\Test" & title & ".dwg", True)
	
	oPath = ThisDoc.Path
	oFileName = ThisDoc.FileName(False) 'without extension
	oRevNum = iProperties.Value("Project", "Revision Number")
	oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
	oDocument = ThisApplication.ActiveDocument
	oContext = ThisApplication.TransientObjects.CreateTranslationContext
	oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
	oOptions = ThisApplication.TransientObjects.CreateNameValueMap
	oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

	'If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
	oOptions.Value("All_Color_AS_Black") = 1
	oOptions.Value("Remove_Line_Weights") = 1
	oOptions.Value("Vector_Resolution") = 400
	oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
	'oOptions.Value("Custom_Begin_Sheet") = 2
	'oOptions.Value("Custom_End_Sheet") = 4
	'End If

	'get PDF target folder path
	oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF"

	'Check for the PDF folder and create it if it does not exist
	If Not System.IO.Directory.Exists(oFolder) Then
	    System.IO.Directory.CreateDirectory(oFolder)
	End If

	 'Set the PDF target file name
	oDataMedium.FileName = oFolder & "\" & oFileName & " Rev" & oRevNum & ".pdf"

	'Publish document
	oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
	
End If




 

0 Likes
Accepted solutions (1)
429 Views
1 Reply
Reply (1)
Message 2 of 2

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

 Hi, I would tell you the same thing about the other thread, being ilogic, delete the Dim line or TextBox As TextBox
Then as a recommendation, when you are creating a code with more and more functions, try using the subroutines.
Then you can more easily turn off calls to subroutines that you know work, and debugging errors becomes easier.
On the other hand, the method you used with the "Here" dialog box is very good!
I hope you can solve your problem. Regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes