.NET

Reply
Active Contributor
dnlo
Posts: 45
Registered: ‎04-11-2003
Message 1 of 7 (124 Views)

C# and ActiveX

124 Views, 6 Replies
04-06-2006 12:50 AM
What is wrong with the code, I have an error at runtime at the last line:

AcadLine lineInSset = (AcadLine)ssetObjectAll.Item((Object)i);
Console.Write("n\{0}", lineInSset.Angle.ToString());

//ssetObjectAll - selection set that contains line entities
// i - index of entity in sel.set

ActiveX help says that Line is accessible through sSet.Item() method..is it something wrong with the cast?

Thank you
*Tony Tanzillo
Message 2 of 7 (124 Views)

Re: C# and ActiveX

04-06-2006 08:30 AM in reply to: dnlo
Break up your code first:

AcadEntity entity = ssetObjectAll.Item(i);
AcadLine line = (AcadLine) entity;

What is the _exact_ text of the error message?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5133905@discussion.autodesk.com...
What is wrong with the code, I have an error at runtime at the last line:

AcadLine lineInSset = (AcadLine)ssetObjectAll.Item((Object)i);
Console.Write("n\{0}", lineInSset.Angle.ToString());

//ssetObjectAll - selection set that contains line entities
// i - index of entity in sel.set

ActiveX help says that Line is accessible through sSet.Item() method..is it something wrong with the cast?

Thank you
Distinguished Contributor
RolandF
Posts: 172
Registered: ‎11-19-2003
Message 3 of 7 (124 Views)

Re: C# and ActiveX

04-06-2006 10:13 AM in reply to: dnlo
I would say that it make problems that you have written "n\" instead of
"\n".

Roland
Active Contributor
dnlo
Posts: 45
Registered: ‎04-11-2003
Message 4 of 7 (124 Views)

Re: C# and ActiveX

04-07-2006 12:23 AM in reply to: dnlo
The error message is:
the object referenced has not been instantiated.

When creating line object with addLine method it is OK.
Extracting object from selection set as AcadEntity OK as well.
But how to convert AcadEntity/IAcadObject to AcadLine in order to get start- endPoints??
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 5 of 7 (124 Views)

Re: C# and ActiveX

04-07-2006 12:51 AM in reply to: dnlo
Maybe this entity is not line?
Active Contributor
dnlo
Posts: 45
Registered: ‎04-11-2003
Message 6 of 7 (124 Views)

Re: C# and ActiveX

04-07-2006 01:32 AM in reply to: dnlo
It is line, entity type AcDbLine. Drawing database contains (testing time) only line entities..
*Tony Tanzillo
Message 7 of 7 (124 Views)

Re: C# and ActiveX

04-07-2006 06:00 AM in reply to: dnlo
The typecast to AcadLine should do that:

AcadLine line = (AcadLine) entity;

If not, step through the code with the debugger
and see if the line variable is getting set.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5135379@discussion.autodesk.com...
The error message is:
the object referenced has not been instantiated.

When creating line object with addLine method it is OK.
Extracting object from selection set as AcadEntity OK as well.
But how to convert AcadEntity/IAcadObject to AcadLine in order to get start- endPoints??

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community