ThisApplication not declared

ThisApplication not declared

dylanTEV9W
Advocate Advocate
758 Views
2 Replies
Message 1 of 3

ThisApplication not declared

dylanTEV9W
Advocate
Advocate

Hi this is probably a super obvious question but oh well. I just completed the my first Add in tutorial without issue. I'm now trying to build out an Add in to do something a little more complicated such as modifying a part parameter. The issue I'm having is that pretty much all the sample code seems to reference something called ThisApplication. When I try to run any sample code it says ThisApplication was not declared. I would take this to mean that I'm not declaring it somewhere but I'm not sure how to do this. Any help would be incredibly appreciated. Thanks 

 

I'll attach the particular bit of code I'm currently having trouble running. 

 

Public Sub SetParameter()

' Get the Parameters object. Assumes a part or assembly document is active.
Dim oParameters As Parameters
oParameters = ThisApplication.ActiveDocument.ComponentDefinition.Parameters

' Get the parameter named "Length".
Dim oLengthParam As Parameter
oLengthParam = oParameters.Item("Length")

' Change the equation of the parameter.
oLengthParam.Expression = "3.5 in"

' Update the document.
ThisApplication.ActiveDocument.Update

End Sub

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

dylanTEV9W
Advocate
Advocate

Found the issue looks like someone else had the same problem about 12 years ago

0 Likes
Message 3 of 3

marcin_otręba
Advisor
Advisor
Accepted solution

i assume that you have declaration in your Public Sub Activate :

  g_inventorApplication = addInSiteObject.Application

 

or something simmilar (look for addInSiteObject.Application)

 

then instead using thisapplication use g_inventorApplication  (or whatever you have)

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes