Property, indexer, or event 'Parameter.Units' is not supported by the language

Property, indexer, or event 'Parameter.Units' is not supported by the language

Anonymous
Not applicable
2,819 Views
5 Replies
Message 1 of 6

Property, indexer, or event 'Parameter.Units' is not supported by the language

Anonymous
Not applicable

Using C#. I recently upgraded to Visual studio 2015 from 2013. I used to obtain the units from Parameter.Get_Units(). Now that doesn't work and when I try to obtain the units from Parameter.Units, I get the following error.

 

Error CS1545 Property, indexer, or event 'Parameter.Units' is not supported by the language; try directly calling accessor methods 'Parameter.get_Units()' or 'Parameter.set_Units(object)' CCSCInvWpr C:\...\ParameterClass.cs 124 Active

 

What can be done to obtain the unit type from the parameter object?

 

Thank you,

 

Eric.....

0 Likes
Accepted solutions (1)
2,820 Views
5 Replies
Replies (5)
Message 2 of 6

wayne.brill
Collaborator
Collaborator

Hi Eric,

 

I tried to recreate this behavior using this SDK sample. (using Visual Studio 2015)

C:\Users\Public\Documents\Autodesk\Inventor 2017\SDK\DeveloperTools\Samples\VCSharp.NET\Standalone Applications\Inventor\AutoBolts

 

I added this code on line 315 in BoltPlacement.cs

                //WB added
                string strUnits = DiamParam.get_Units();

 

I am not getting any errors and I see the Units returned when I debug. Can you try using that sample and let me know the results you get?

 

What version of Inventor interop is being referenced?

 

Thanks,

Wayne 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Wayne,

I'm using Inventor 2015 and was referencing the 2016 dll. I switched to the 2017 dll this morning with the same result. It's important to note that the error doesn't occur at compile time; it only occurs during run-time. 

 

I cannot install the developertools.msi because it states that no version of Visual Studio can be found. 

 

Could this be a .NET conflict issue with Inv 2015, VS 2015 and the newer Inv dll's? I ask because my old machine had VS 2013 and everything worked fine. My Win 7 Enterprise machine is using 4.6.01055

 

        protected string _getUnitsFromParameter(Parameter _param)
        {            
            try
            { return _param.get_Units(); }
            catch (Exception _ex)
            { UpdateLog("_getUnitsFromParameter", _ex); }

// Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND)) // Set a reference to the blank space in the expression string. int _index = _param.Expression.IndexOf(" ", StringComparison.Ordinal); return _index != -1 ? _param.Expression.Substring(_index + 1) : ""; }

 

0 Likes
Message 4 of 6

wayne.brill
Collaborator
Collaborator

Hi Eric,

 

I am now able to recreate this behavior if the "Embed Interop Types" setting for the Inventor Interop is set to True. Please check this setting and if it is True make if False.

 

Thanks,

Wayne

 

Embed_Interop_Types_WB.jpg

 

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 5 of 6

Anonymous
Not applicable

Wayne,

 

Unfortunately, that causes me other problems (see inserted code). At this point, I've created a simple VB project with one class with one function that returns a parameter's units value. Is there any chance this could get fixed in the API?

 

Thanks for your help

 

Eric...

 

        public void SetCompVisibility(int _viewIndex, string _assyFileName, bool _visibility)
        {
            // Set a reference to a drawing view.
            DrawingView _drawView = GetDrawingView(_viewIndex);

            foreach (DrawingCurve _dwgCurve in _drawView.DrawingCurves)
            {
                // Set a reference to the occurrence proxy represented by this drawing curve.
// If embedded is turned off, then the model geometry doesn't contain a definition for "ContainingOccurrence" ComponentOccurrenceProxy _occPxy = _dwgCurve.ModelGeometry.ContainingOccurrence; if (!_occPxy.Name.ToUpper().Contains(_assyFileName.ToUpper())) continue; _drawView.SetVisibility(_occPxy, _visibility); SetCompVisibility(_viewIndex, _assyFileName, _visibility); break; } }
0 Likes
Message 6 of 6

wayne.brill
Collaborator
Collaborator
Accepted solution

Hi Eric,

 

I asked a colleague in Engineering about this and they suggest setting "Embed Interop Types" to False.

 

>> >>

Please just ask the user to set the Embed Interop Types to False for the project, set it to True may cause some problems when use Inventor APIs. If users create an Inventor addin using our Addin Wizard then this property is set to False by the wizard.

<< <<

 

Maybe using late binding will be the solution for ModelGeometry.ContainingOccurrence. Here is the code that works in my tests with  "Embed Interop Types" = False.

 

 //WB commented
            //  foreach (DrawingCurve _dwgCurve in _drawView.DrawingCurves)
            foreach (dynamic _dwgCurve in _drawView.DrawingCurves)
            {
                // Set a reference to the occurrence proxy represented by this drawing curve.
                // If embedded is turned off, then the model geometry doesn't contain a definition for "ContainingOccurrence"
                //WB - this is working with "Embed Interop Types" = False
                ComponentOccurrenceProxy _occPxy = (ComponentOccurrenceProxy)_dwgCurve.ModelGeometry.ContainingOccurrence;
               
                //if (!_occPxy.Name.ToUpper().Contains(_assyFileName.ToUpper())) continue;
                //_drawView.SetVisibility(_occPxy, _visibility);
                //SetCompVisibility(_viewIndex, _assyFileName, _visibility);
                //break;
            }

 

 

 

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network