.NET

Reply
Active Member
ethiel
Posts: 8
Registered: ‎12-18-2008
Message 21 of 26 (121 Views)

Re: Obtain point coordinates froma dwg file through .net

12-21-2008 02:19 PM 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.
*Tony Tanzillo
Message 22 of 26 (121 Views)

Re: Obtain point coordinates froma dwg file through .net

12-21-2008 08:35 PM 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.
:smileyvery-happy: I can post my
code?.
*Paul Richardson
Message 23 of 26 (121 Views)

Re: Obtain point coordinates froma dwg file through .net

12-22-2008 05:00 AM 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. :smileyvery-happy: I can post my
code?.
*Paul Richardson
Message 24 of 26 (121 Views)

Re: Obtain point coordinates froma dwg file through .net

12-22-2008 05:17 AM 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. :smileyvery-happy: I can post my
code?.
*Tony Tanzillo
Message 25 of 26 (121 Views)

Re: Obtain point coordinates froma dwg file through .net

12-22-2008 10:45 AM 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. :smileyvery-happy: I can post my
code?.
*Paul Richardson
Message 26 of 26 (121 Views)

Re: Obtain point coordinates froma dwg file through .net

12-22-2008 03:53 PM 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. :smileyvery-happy: I can post my
code?.
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 or visit the Installation and Licensing Forum to get help installing your software.