Ilogic: Object reference not set to an instance of an object.

Ilogic: Object reference not set to an instance of an object.

sreed
Enthusiast Enthusiast
951 Views
2 Replies
Message 1 of 3

Ilogic: Object reference not set to an instance of an object.

sreed
Enthusiast
Enthusiast

I have a form in my .idw that fills in my title block and I have a two rules that reach out to the model so that I can change the design state of the model from the .idw.  I can get this to work in a new drawing but when I open and existing drawing and input the form and rules I get errors when it comes to the design state of the model.

I get and error that the "Object reference not set to an instance of an object."  Can some one help me out?

 

I have attached a .idw and the two rules.

 

Thanks,

Steve

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

johnsonshiue
Community Manager
Community Manager

Hi! Is it possible the existing drawing does not have parameter "ModelDesignState" defined?

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@sreed,

 

Try below changes in both iLogic code.

 

Get Reference assembly

 

Dim oDoc As DrawingDocument 
oDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

oSheet = ActiveSheet.Sheet

oViews = oSheet.DrawingViews

If oViews.Count > 0 Then
	oView = oViews.Item(1)
	oModelName = oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
	
	Dim referDoc As Document
	referDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
	
	oAssemblyState = referDoc.PropertySets.Item("Design Tracking Properties").Item("Design Status").Value
	If oAssemblyState = 1 Then
		oAssemblyState = "WorkInProgress"
		Else If oAssemblyState = 2 Then
		oAssemblyState = "Pending"
		Else If oAssemblyState = 3 Then
		oAssemblyState = "Released"
	End If
	'MessageBox.Show(oAssemblyState, "Assembly State")

	Parameter("ModelDesignState") = oAssemblyState

End If

 

Push Design State

 

 

Dim oDoc As DrawingDocument 
oDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

oSheet = ActiveSheet.Sheet

oViews = oSheet.DrawingViews

If oViews.Count > 0 Then

	oView = oViews.Item(1)
	oModelName = oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
	Dim referDoc As Document 
	referDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
	'MessageBox.Show(oModelName, "Assembly Name")
	oNewState = Parameter.Value("ModelDesignState")
	'MessageBox.Show(oNewState, "Model Design State")

	oAssemblyState = Parameter.Value("ModelDesignState")

	If oAssemblyState = "WorkInProgress" Then
		oAssemblyState = 1
		Else If oAssemblyState = "Pending" Then
		oAssemblyState = 2
		Else If oAssemblyState = "Released" Then
		oAssemblyState = 3
	End If
	referDoc.PropertySets.Item("Design Tracking Properties").Item("Design Status").Value = oAssemblyState

	'iProperties.Value(oModelName, "Status", "Design State") = oAssemblyState

End If

 Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes