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

Obtain point coordinates froma dwg file through .net

25 REPLIES 25
Reply
Message 1 of 26
ethiel
635 Views, 25 Replies

Obtain point coordinates froma dwg file through .net

Good afternoon.

¿it can be possible to get point coordinates or line coordinates from a dwg file using .net language?.

Im spanish, please, sorry for my poor english.
25 REPLIES 25
Message 21 of 26
ethiel
in reply to: ethiel

http://rapidshare.com/files/175593183/Program.rar

This is my code. It's divided in 4 parts. There are four classes written in C#.

Greetings.
Message 22 of 26
Anonymous
in reply to: ethiel


It looks like its also mangled from a newsreader,
because

the Line variable is a vertical bar (illegal). I'm curious as
to

how that was mangled. What as the actual variable
used?

 

I'm just becoming more and more convinced that
what's

actually going with the discussion group nonsense, is

deliberate, malicious sabotage, with little regards for
how

bad it makes the entire organization look.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6093915@discussion.autodesk.com">news:6093915@discussion.autodesk.com
...


this is still unreadable in the Webreader... I
give.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6093914@discussion.autodesk.com">news:6093914@discussion.autodesk.com
...


[code]

using (Transaction tr =
   
doc.TransactionManager.StartTransaction())
{
   
foreach (ObjectId id in ids)
   
{
        Entity e =

           
(Entity)tr.GetObject
         
        (id, OpenMode.ForRead);

 

        Line
l = e as Line;
        if (l !=
null)
       
{
           
outPut
+=
               
(string.Format
                   
("Line startpoint:{0}\n",

                       
l.StartPoint));
           
continue;
        }

 

       
DBPoint p = e as DBPoint;
        if
(p != null)
       
{
           
outPut
+=
               
(string.Format
                   
("Point position:{0}\n",

                       
p.Position));
           
continue;
        }

 

       
//...
    }
}

[/code]


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message

href="news:6093912@discussion.autodesk.com">news:6093912@discussion.autodesk.com
...


Sure - post how you did it so others can
see.

 

This idea works for me...

{code}

using (Transaction tr =

   
doc.TransactionManager.StartTransaction())
{
   
foreach (ObjectId id in ids)
   
{
        Entity e =

           
(Entity)tr.GetObject
         
        (id, OpenMode.ForRead);

 

       
Line l = e as Line;
        if (l !=
null)
       
{
           
outPut
+=
               
(string.Format
                   
("Line startpoint:{0}\n",

                       
l.StartPoint));
           
continue;
        }

 

       
DBPoint p = e as DBPoint;
        if
(p != null)
       
{
           
outPut
+=
               
(string.Format
                   
("Point position:{0}\n",

                       
p.Position));
           
continue;
        }

 

       
//...
    }
}

{code}


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have obtained all I needed. Many thanks to all for replies and help me.
😄 I can post my
code?.
Message 23 of 26
Anonymous
in reply to: ethiel


Just bad naming on my part... It's a lower case L.
I do think they changed my lower case Ls to

pipes in earlier code I've posted though. At the
time I thought I was nuts...

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


It looks like its also mangled from a newsreader,
because

the Line variable is a vertical bar (illegal). I'm curious
as to

how that was mangled. What as the actual variable
used?

 

I'm just becoming more and more convinced that
what's

actually going with the discussion group nonsense, is

deliberate, malicious sabotage, with little regards for
how

bad it makes the entire organization look.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6093915@discussion.autodesk.com">news:6093915@discussion.autodesk.com
...


this is still unreadable in the Webreader... I
give.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message

href="news:6093914@discussion.autodesk.com">news:6093914@discussion.autodesk.com
...


[code]

using (Transaction tr =

   
doc.TransactionManager.StartTransaction())
{
   
foreach (ObjectId id in ids)
   
{
        Entity e =

           
(Entity)tr.GetObject
         
        (id, OpenMode.ForRead);

 

       
Line l = e as Line;
        if (l !=
null)
       
{
           
outPut
+=
               
(string.Format
                   
("Line startpoint:{0}\n",

                       
l.StartPoint));
           
continue;
        }

 

       
DBPoint p = e as DBPoint;
        if
(p != null)
       
{
           
outPut
+=
               
(string.Format
                   
("Point position:{0}\n",

                       
p.Position));
           
continue;
        }

 

       
//...
    }
}

[/code]


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message

href="news:6093912@discussion.autodesk.com">news:6093912@discussion.autodesk.com
...


Sure - post how you did it so others can
see.

 

This idea works for me...

{code}

using (Transaction tr =

   
doc.TransactionManager.StartTransaction())
{
   
foreach (ObjectId id in ids)
   
{
        Entity e =

           
(Entity)tr.GetObject
     
            (id,
OpenMode.ForRead);

 

       
Line l = e as Line;
        if (l
!= null)
       
{
           
outPut
+=
               
(string.Format
                   
("Line startpoint:{0}\n",

                       
l.StartPoint));
           
continue;
        }

 

       
DBPoint p = e as DBPoint;
       
if (p != null)
       
{
           
outPut
+=
               
(string.Format
                   
("Point position:{0}\n",

                       
p.Position));
           
continue;
        }

 

       
//...
    }
}

{code}


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have obtained all I needed. Many thanks to all for replies and help
me. 😄 I can post my
code?.
Message 24 of 26
Anonymous
in reply to: ethiel


Tony - care to share how you step through and
check type? Everything I've read says not to

use if (typeof(...)) else if (...). Casting using
'as' seems to be a good solution.

 

Thanks!


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


It looks like its also mangled from a newsreader,
because

the Line variable is a vertical bar (illegal). I'm curious
as to

how that was mangled. What as the actual variable
used?

 

I'm just becoming more and more convinced that
what's

actually going with the discussion group nonsense, is

deliberate, malicious sabotage, with little regards for
how

bad it makes the entire organization look.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6093915@discussion.autodesk.com">news:6093915@discussion.autodesk.com
...


this is still unreadable in the Webreader... I
give.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message

href="news:6093914@discussion.autodesk.com">news:6093914@discussion.autodesk.com
...


[code]

using (Transaction tr =

   
doc.TransactionManager.StartTransaction())
{
   
foreach (ObjectId id in ids)
   
{
        Entity e =

           
(Entity)tr.GetObject
         
        (id, OpenMode.ForRead);

 

       
Line l = e as Line;
        if (l !=
null)
       
{
           
outPut
+=
               
(string.Format
                   
("Line startpoint:{0}\n",

                       
l.StartPoint));
           
continue;
        }

 

       
DBPoint p = e as DBPoint;
        if
(p != null)
       
{
           
outPut
+=
               
(string.Format
                   
("Point position:{0}\n",

                       
p.Position));
           
continue;
        }

 

       
//...
    }
}

[/code]


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message

href="news:6093912@discussion.autodesk.com">news:6093912@discussion.autodesk.com
...


Sure - post how you did it so others can
see.

 

This idea works for me...

{code}

using (Transaction tr =

   
doc.TransactionManager.StartTransaction())
{
   
foreach (ObjectId id in ids)
   
{
        Entity e =

           
(Entity)tr.GetObject
     
            (id,
OpenMode.ForRead);

 

       
Line l = e as Line;
        if (l
!= null)
       
{
           
outPut
+=
               
(string.Format
                   
("Line startpoint:{0}\n",

                       
l.StartPoint));
           
continue;
        }

 

       
DBPoint p = e as DBPoint;
       
if (p != null)
       
{
           
outPut
+=
               
(string.Format
                   
("Point position:{0}\n",

                       
p.Position));
           
continue;
        }

 

       
//...
    }
}

{code}


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have obtained all I needed. Many thanks to all for replies and help
me. 😄 I can post my
code?.
Message 25 of 26
Anonymous
in reply to: ethiel


typeof( typename ) returns a type, which you can compare
to

another type, but that's something I do only if I want to
know

if the two types are the exact same type.

 

Usually I don't want to know that. Rather, I want to know
if

a given object is an instance of a given type, or any
derived

type, which is what the 'is' operator does.

 

If you have two types and want to know if one is derived
from

the other you can use Type.IsAssignableFrom(type), which
is

true if the type you call it on, is the type you pass, or any
base

type.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6094121@discussion.autodesk.com">news:6094121@discussion.autodesk.com
...


Tony - care to share how you step through
and check type? Everything I've read says not to

use if (typeof(...)) else if (...). Casting using
'as' seems to be a good solution.

 

Thanks!


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


It looks like its also mangled from a newsreader,
because

the Line variable is a vertical bar (illegal). I'm curious
as to

how that was mangled. What as the actual variable
used?

 

I'm just becoming more and more convinced that
what's

actually going with the discussion group nonsense, is

deliberate, malicious sabotage, with little regards for
how

bad it makes the entire organization look.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD
2000 through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message

href="news:6093915@discussion.autodesk.com">news:6093915@discussion.autodesk.com
...


this is still unreadable in the Webreader...
I give.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message

href="news:6093914@discussion.autodesk.com">news:6093914@discussion.autodesk.com
...


[code]

using (Transaction tr =

   
doc.TransactionManager.StartTransaction())
{
   
foreach (ObjectId id in ids)
   
{
        Entity e =

           
(Entity)tr.GetObject
     
            (id,
OpenMode.ForRead);

 

       
Line l = e as Line;
        if (l
!= null)
       
{
           
outPut
+=
               
(string.Format
                   
("Line startpoint:{0}\n",

                       
l.StartPoint));
           
continue;
        }

 

       
DBPoint p = e as DBPoint;
       
if (p != null)
       
{
           
outPut
+=
               
(string.Format
                   
("Point position:{0}\n",

                       
p.Position));
           
continue;
        }

 

       
//...
    }
}

[/code]


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in
message
href="news:6093912@discussion.autodesk.com">news:6093912@discussion.autodesk.com
...


Sure - post how you did it so others can
see.

 

This idea works for me...

{code}

using (Transaction tr =

   
doc.TransactionManager.StartTransaction())
{
   
foreach (ObjectId id in ids)
   
{
        Entity e =

           
(Entity)tr.GetObject
     
            (id,
OpenMode.ForRead);

 


size=2>        Line l = e as
Line;
        if (l !=
null)
       
{
           
outPut
+=
               
(string.Format
                   
("Line startpoint:{0}\n",

                       
l.StartPoint));
           
continue;
        }

 


size=2>        DBPoint p = e as
DBPoint;
        if (p !=
null)
       
{
           
outPut
+=
               
(string.Format
                   
("Point position:{0}\n",

                       
p.Position));
           
continue;
        }

 


size=2>       
//...
    }
}

{code}


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have obtained all I needed. Many thanks to all for replies and help
me. 😄 I can post my
code?.
Message 26 of 26
Anonymous
in reply to: ethiel


Thank you.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


typeof( typename ) returns a type, which you can compare
to

another type, but that's something I do only if I want to
know

if the two types are the exact same type.

 

Usually I don't want to know that. Rather, I want to know
if

a given object is an instance of a given type, or any
derived

type, which is what the 'is' operator does.

 

If you have two types and want to know if one is derived
from

the other you can use Type.IsAssignableFrom(type), which
is

true if the type you call it on, is the type you pass, or
any base

type.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message
href="news:6094121@discussion.autodesk.com">news:6094121@discussion.autodesk.com
...


Tony - care to share how you step through
and check type? Everything I've read says not to

use if (typeof(...)) else if (...). Casting
using 'as' seems to be a good solution.

 

Thanks!


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


It looks like its also mangled from a newsreader,
because

the Line variable is a vertical bar (illegal). I'm
curious as to

how that was mangled. What as the actual variable
used?

 

I'm just becoming more and more convinced that
what's

actually going with the discussion group nonsense, is

deliberate, malicious sabotage, with little regards for
how

bad it makes the entire organization look.


 

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD
2000 through 2009

href="http://www.acadxtabs.com">http://www.acadxtabs.com

 


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in message

href="news:6093915@discussion.autodesk.com">news:6093915@discussion.autodesk.com
...


this is still unreadable in the
Webreader... I give.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in
message
href="news:6093914@discussion.autodesk.com">news:6093914@discussion.autodesk.com
...


[code]

using (Transaction tr =

   
doc.TransactionManager.StartTransaction())
{
   
foreach (ObjectId id in ids)
   
{
        Entity e =

           
(Entity)tr.GetObject
     
            (id,
OpenMode.ForRead);

 


size=2>        Line l = e as
Line;
        if (l !=
null)
       
{
           
outPut
+=
               
(string.Format
                   
("Line startpoint:{0}\n",

                       
l.StartPoint));
           
continue;
        }

 


size=2>        DBPoint p = e as
DBPoint;
        if (p !=
null)
       
{
           
outPut
+=
               
(string.Format
                   
("Point position:{0}\n",

                       
p.Position));
           
continue;
        }

 


size=2>       
//...
    }
}

[/code]


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Paul Richardson" <prichardson<lastpoint> wrote in
message
href="news:6093912@discussion.autodesk.com">news:6093912@discussion.autodesk.com
...


Sure - post how you did it so others
can see.

 

This idea works for me...

{code}

using (Transaction tr =

   
doc.TransactionManager.StartTransaction())
{
   
foreach (ObjectId id in ids)
   
{
        Entity e =

           
(Entity)tr.GetObject
     
            (id,
OpenMode.ForRead);

 


size=2>        Line l = e as
Line;
        if (l !=
null)
       
{
           
outPut
+=
               
(string.Format
                   
("Line startpoint:{0}\n",

                       
l.StartPoint));
           
continue;
       
}

 


size=2>        DBPoint p = e as
DBPoint;
        if (p !=
null)
       
{
           
outPut
+=
               
(string.Format
                   
("Point position:{0}\n",

                       
p.Position));
           
continue;
       
}

 


size=2>       
//...
    }
}

{code}


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have obtained all I needed. Many thanks to all for replies and
help me. 😄 I can post my
code?.

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