.NET

.NET

Reply
*Paul Richardson
Message 11 of 26 (168 Views)

Re: Obtain point coordinates froma dwg file through .net

12-18-2008 09:45 AM in reply to: ethiel

Here is bit more detailed filter list.  - Net
version of the LISP help menu filter.

 

//all circles with radius of 1 and all line on
layer "ABC"
TypedValue[] fList = new TypedValue[10];

 

fList[0] = new TypedValue((int)DxfCode.Operator,
"<OR");

 

fList[1] = new
TypedValue((int)DxfCode.Operator,"<AND");
fList[2] = new
TypedValue((int)DxfCode.Start,"CIRCLE");
fList[3] = new
TypedValue((int)DxfCode.Real, 1.0);
fList[4] = new
TypedValue((int)DxfCode.Operator, "AND>");

 

fList[5] = new TypedValue((int)DxfCode.Operator,
"<AND");
fList[6] = new TypedValue((int)DxfCode.Start,
"Line");
fList[7] = new TypedValue((int)DxfCode.LayerName,
"ABC");
fList[8] = new TypedValue((int)DxfCode.Operator,
"AND>");

 

fList[9] = new TypedValue((int)DxfCode.Operator,
"OR>");

 

SelectionFilter sf = new
SelectionFilter(fList);

 

//LISP filter from help menu.
// '(
// (-4 .
"<OR")
// (-4 . "<AND")
// (0 . "CIRCLE")
// (40 . 1.0)
// (-4
. "AND>")
// (-4 . "<AND")
// (0 . "LINE")
// (8 . "ABC")
//
(-4 . "AND>")
// (-4 . "OR>")
// )
//)


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
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.
Active Member
ethiel
Posts: 8
Registered: ‎12-18-2008
Message 12 of 26 (168 Views)

Re: Obtain point coordinates froma dwg file through .net

12-18-2008 10:14 AM in reply to: ethiel
Many thanks to all.
I have readed this code, but I have a doubt.

If I can obtain object property I must pick on it.

It's possible to achieve identities (for example, only points) of a dwg without picking on it?.

I can obtain the layer but I can't access to entities inside it.

It's possible?.
*Paul Richardson
Message 13 of 26 (168 Views)

Re: Obtain point coordinates froma dwg file through .net

12-18-2008 10:38 AM in reply to: ethiel

If I understand correctly you want to create a
selection set of all objects and output specific points depending

on the object type?

 

You can extend what you select by using a comma
seperated list for your objects or use no filter and grab all
entities.

face=Arial color=#000000>"POINT,LINE,CIRCLE"


color=#000000>
 


color=#000000>You'll have to check the type of entity in your loop and cast as
necessary. Then you can extract what you need.

color=#a31515 size=2>


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Many
thanks to all. I have readed this code, but I have a doubt. If I can obtain
object property I must pick on it. It's possible to achieve identities (for
example, only points) of a dwg without picking on it?. I can obtain the layer
but I can't access to entities inside it. It's
possible?.
Active Member
ethiel
Posts: 8
Registered: ‎12-18-2008
Message 14 of 26 (168 Views)

Re: Obtain point coordinates froma dwg file through .net

12-19-2008 02:09 AM in reply to: ethiel
Many thanks.
I can obtain all I need.
Only I need to know how get X-Y Coordinates of a entity.

Many thanks. I'ts very useful.
*Paul Richardson
Message 15 of 26 (168 Views)

Re: Obtain point coordinates froma dwg file through .net

12-19-2008 05:45 AM in reply to: ethiel

Which entity and which xy coords??? Try typing a
dot and looking at the properties for the entity

to find the cood you want...


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Many
thanks. I can obtain all I need. Only I need to know how get X-Y Coordinates
of a entity. Many thanks. I'ts very useful.
*Paul Richardson
Message 16 of 26 (168 Views)

Re: Obtain point coordinates froma dwg file through .net

12-20-2008 06:53 PM in reply to: ethiel

Check out this post...



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
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.
Active Member
ethiel
Posts: 8
Registered: ‎12-18-2008
Message 17 of 26 (168 Views)

Re: Obtain point coordinates froma dwg file through .net

12-21-2008 05:17 AM in reply to: ethiel
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 18 of 26 (168 Views)

Re: Obtain point coordinates froma dwg file through .net

12-21-2008 08:02 AM in reply to: ethiel

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 19 of 26 (168 Views)

Re: Obtain point coordinates froma dwg file through .net

12-21-2008 08:27 AM in reply to: ethiel

[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 20 of 26 (168 Views)

Re: Obtain point coordinates froma dwg file through .net

12-21-2008 08:29 AM in reply to: ethiel

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?.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.