Compile Error: Object Required - Inventor API

Compile Error: Object Required - Inventor API

Mark.Lancaster
Consultant Consultant
1,009 Views
2 Replies
Message 1 of 3

Compile Error: Object Required - Inventor API

Mark.Lancaster
Consultant
Consultant

After about 3 to 4 years of not programming, I'm getting back into it and using the Inventor API, so yes a newbie..  😁

 

Ran into an issue and trying to figure out why I'm getting a Compile Error.   This program is nothing big and just want a message box to show the radius of all the fillet features in my part file.

Private Sub Codeme()

Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument


Dim oFilletFeatures As FilletFeatures
Set oFilletFeatures = oPartDoc.ComponentDefinition.Features.FilletFeatures

Dim Counter As Integer

For Counter = 1 To oFilletFeatures.Count
    Dim oFillet As FilletFeature
    Set oFillet = oFilletFeatures.Item(Counter)
    Dim oFS As ModelParameter
    Set oFS = oFillet.FeatureDimensions.Item(1)
    Dim oFS1 As Double
    Set oFS1 = oFS.Parameter.ModelValue
    MsgBox (oFS.Parameter.ModelValue)
Next

Why in the world is the line of Set oFS1 = giving me this error?    When ModelValue type is "double".   But I can take the oFS.Parameter.ModelValue statement and use it directly with the MsgBox line and I see the fillet information I need...

 

2019-08-28_18-14-54.jpg

 

Working in 2020 if that makes a difference...

 

Update:  Yes there's probably others ways this entire program can be coded..   I'm not looking for a redo of the entire program.  Just an answer in why this given line is throwing a fit.  Thanks...

 

 

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

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

HideoYamada
Advisor
Advisor
Accepted solution

Hello Mark,

 

"Set" is not need for double. "Set" is used for objects.

I can't explain why sometimes needed , or not needed. Because it's difficult to say with my poor English ability.

But you will find the answer by using google.

Capture.PNG

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
Message 3 of 3

Mark.Lancaster
Consultant
Consultant

@HideoYamada 

 

Thanks for the reply and answer..  I thought that earlier but when i changed it I saw another error .   So I was confused.   But I just realized the new error was associated to another portion of the code.   In the end..  2 rookie mistakes..  😃.

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

0 Likes