iLogic Error The object reference was not set to an object instance

iLogic Error The object reference was not set to an object instance

mk92
Collaborator Collaborator
624 Views
2 Replies
Message 1 of 3

iLogic Error The object reference was not set to an object instance

mk92
Collaborator
Collaborator

Hi,

I took the code from this help page:

Autodesk Help Page

 

And made this out of it (just an extraction):

Dim newInst2 As Autodesk.Factory.PublicAPI.Objects.v2.AssetInstance = New Autodesk.Factory.PublicAPI.Objects.v2.AssetInstance() With {
            .AssetID = "41c84844-7b28-4903-bebd-365ca3a6a53c",	
		.Position = New System.Windows.Media.Media3D.Matrix3D() With {
            .OffsetX = -200,
            .OffsetY = 0,
            .OffsetZ = 0
        }
    }
newInst2.Parameters("Length") = "400"

The code runs great until I want to change the Length. Then is says;

 

The object reference was not set to an object instance.

 

I thought "Dim newInst2 As ...." is doing exactly this. What is missing here?

 

Thank you.

0 Likes
625 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor

Does the parameter "Length" exist?

Otherwise create it first!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 3

mk92
Collaborator
Collaborator

Yes the parameter Length definitely exists.

 

If I do it like this:

Dim Layout As Document = ThisApplication.ActiveDocument	
Dim insts = api.AddAssetInstances(Layout, New Autodesk.Factory.PublicAPI.Currency.v2.IAssetInstance() {newInst1, newInst2, newInst3 })

Dim Test = api.GetAssetInstances(Layout)
For Each item In Test
	item.Parameters("Length") = "400"
Next
api.UpdateAssetInstances(Layout, Test)

It works fine, but for each asset with the parameter Length.

 

 

But I only want to edit specific assets. And for the best workflow right after they are placed in my layout.

0 Likes