Code Red > .NET

try directly calling accessor methods ????

(1/3) > >>

Jeff_M:
I've gotten a bit more comfortable using C# with C3D2007 & 2008, thanks to Sinc's C3D utilities, but now I've come across this little problem that I'm stuck on. I've got code that works, up until I try to access a point group's pointstyle.

string strStylName = ptGroup.PointStyle.Name;

or

IAeccPointStyle grpStyle = ptGroup.PointStyle;

these both raise errors in VS when I attempt to build the project. This is the error:

Property, indexer, or event 'PointStyle' is not supported by the language; try directly calling accessor methods 'Autodesk.AECC.Interop.Land.IAeccPointGroup.get_PointStyle()' or 'Autodesk.AECC.Interop.Land.IAeccPointGroup.set_PointStyle(object)'

then this, too, fails:

IAeccPointStyle grpStyle = Autodesk.AECC.Interop.Land.IAeccPointGroup.get_PointStyle(ptGroup);

as does

IAeccPointStyle grpStyle = Autodesk.AECC.Interop.Land.IAeccPointGroup.get_PointStyle();

Any ideas on how to proceed?

TonyT:
IAeccPointStyle is a COM interface, which you generally
don't use directly in managed code. You usually use the
CCW (COM-Callable Wrapper) that wraps and implements
the COM interface.

Typecast it to an AeccPointStyle or AeccPointStyleClass


--- Quote from: Jeff_M on April 22, 2007, 03:42:52 PM ---I've gotten a bit more comfortable using C# with C3D2007 & 2008, thanks to Sinc's C3D utilities, but now I've come across this little problem that I'm stuck on. I've got code that works, up until I try to access a point group's pointstyle.

string strStylName = ptGroup.PointStyle.Name;

or

IAeccPointStyle grpStyle = ptGroup.PointStyle;

these both raise errors in VS when I attempt to build the project. This is the error:

Property, indexer, or event 'PointStyle' is not supported by the language; try directly calling accessor methods 'Autodesk.AECC.Interop.Land.IAeccPointGroup.get_PointStyle()' or 'Autodesk.AECC.Interop.Land.IAeccPointGroup.set_PointStyle(object)'

then this, too, fails:

IAeccPointStyle grpStyle = Autodesk.AECC.Interop.Land.IAeccPointGroup.get_PointStyle(ptGroup);

as does

IAeccPointStyle grpStyle = Autodesk.AECC.Interop.Land.IAeccPointGroup.get_PointStyle();

Any ideas on how to proceed?


--- End quote ---

Jeff_M:

--- Quote from: TonyT on April 22, 2007, 06:35:07 PM ---Typecast it to an AeccPointStyle or AeccPointStyleClass

--- End quote ---
Thanks, Tony. I originally had my code that way. I get the same errors using either of those.

I'm starting to think that something wasn't included in the wrapper to allow access to the PointStyle objects. The Object Browser seems to say otherwise, but when I Inspect the returned object in Debug mode for a PointGroup it is shown as {System._ComObject} instead of the AeccPointGroup that I would've expected. Attached is screen shot showing how all the other Aecc objects are as expected, but the PointGroup is not. Since it is from this Object that I'm trying to get the PointStyle, could this be why I'm having problems with this? It didn't get in the pic, but the ptGroup variable is TypeCast as AeccPointGroup.

Of course, this all may be more due to my inexperience with the language.

sinc:
Did you try using the AcadObject or FromAcadObject methods from the DBObject class?

TonyT:
Your code doesn't show what the ptGroup variable is declared as.

Also, there may be an issue with COM reference counting since
the scope of the PointGroup objects is the foreach() block, and
it may be that Release() is being called on each grp (the foreach
variable), which invalidates the reference to the object.

So just guessing here, you might try something like this:

   Within your foreach() loop where you assign ptGroup:


--- Code: ---
         ptGroup = grp;
         Marshal.AddRef(Marshal.GetIUnknownForObject(ptGroup));


--- End code ---

If that doesn't work, then you might also try:


--- Code: ---
         AeccPointGroupClass group =
           (AeccPointGroupClass) = Marshal.CreateWrapperOfType( grp,
                 typeof(AeccPointGroupClass));


--- End code ---


--- Quote from: Jeff_M on April 22, 2007, 08:50:06 PM ---
--- Quote from: TonyT on April 22, 2007, 06:35:07 PM ---Typecast it to an AeccPointStyle or AeccPointStyleClass

--- End quote ---
Thanks, Tony. I originally had my code that way. I get the same errors using either of those.

I'm starting to think that something wasn't included in the wrapper to allow access to the PointStyle objects. The Object Browser seems to say otherwise, but when I Inspect the returned object in Debug mode for a PointGroup it is shown as {System._ComObject} instead of the AeccPointGroup that I would've expected. Attached is screen shot showing how all the other Aecc objects are as expected, but the PointGroup is not. Since it is from this Object that I'm trying to get the PointStyle, could this be why I'm having problems with this? It didn't get in the pic, but the ptGroup variable is TypeCast as AeccPointGroup.

Of course, this all may be more due to my inexperience with the language.

--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version