.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Selecting an entity

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
235 Views, 3 Replies

Selecting an entity

Hello,

When I draw an object in Autocad and try to select with GetEntity I get System.__ComObject. I can do a cast to AcadEntity, but if I try to do a cast to the drawing object (AcadLine, AcadText...) I obtain a null reference.

object returnObjt = new object();
object pt = new object();
try
{
app.ActiveDocument.Utility.GetEntity(out returnObjt, out pt, "Selecciona un trazado:");

}
catch (Exception ex)
{
MessageBox.Show("Nada seleccionado");
return null;
}

AcadEntity o = returnObjt as AcadEntity;
AcadPolyline linea = returnObjt as AcadPolyline;

If I select an object created by code (pline = app.ActiveDocument.ModelSpace.AddPolyline(puntosSector);) it works perfectly
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

I would need to ask you if you have any experience with
AutoCAD and/or AutoCAD programming.

If not, please tell us, so we know you are not just missing
something very basic and obvious to most, like for example,
knowing the difference between an AcadPolyline and an
AcadLWPolyline.

In addition, because you are using the ActiveX API, you
can get better help on it in the VBA newsgroup, where it
is routinely discussed.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5820494@discussion.autodesk.com...
Hello,

When I draw an object in Autocad and try to select with GetEntity I get System.__ComObject. I can do a cast to AcadEntity, but if I try to do a cast to the drawing object (AcadLine, AcadText...) I obtain a null reference.

object returnObjt = new object();
object pt = new object();
try
{
app.ActiveDocument.Utility.GetEntity(out returnObjt, out pt, "Selecciona un trazado:");

}
catch (Exception ex)
{
MessageBox.Show("Nada seleccionado");
return null;
}

AcadEntity o = returnObjt as AcadEntity;
AcadPolyline linea = returnObjt as AcadPolyline;

If I select an object created by code (pline = app.ActiveDocument.ModelSpace.AddPolyline(puntosSector);) it works perfectly
Message 3 of 4
Anonymous
in reply to: Anonymous

To tell the truth when I started this project two moths ago I had no idea of AutoCAD, so I really I don't know the diference between AcadPolyline and AcadLWPolyline.

By what you say I supose that when I draw a polyline in AutoCAD, I obtain an AcadLWPolyline. Thanks
Message 4 of 4
Anonymous
in reply to: Anonymous

You should probably consider some basic AutoCAD training
(user-level that is), because without that you will be wasting
a lot of time.

In answer to your supposition, AutoCAD supports two basic
types of 2D polylines, called 'light' and 'heavy'. You could
encounter either of them in a drawing, and which is created
when you use the PLINE command depends on the value of
the PLINETYPE system variable.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5821626@discussion.autodesk.com...
To tell the truth when I started this project two moths ago I had no idea of AutoCAD, so I really I don't know the diference between AcadPolyline and AcadLWPolyline.

By what you say I supose that when I draw a polyline in AutoCAD, I obtain an AcadLWPolyline. Thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost