.NET

Reply
Valued Contributor
HelloWorlddd
Posts: 87
Registered: ‎05-03-2013
Message 1 of 13 (341 Views)
Accepted Solution

Key Point

341 Views, 12 Replies
12-27-2013 01:41 AM

   Please see the attachment first

 

   I want to create a command which has a effect,

 

   First, the user is prompted to select the line,
   Second, the program execute and determine, find the key points
   Finally, fix this line, let the distance from the right end point of line to circleis right just 1.

 

   If there is no solution, then the situation becomes simpler, only the case2: the line connect the circle, perhaps easier

 

   Note: The line and the circle in different layer

 

   I have this idea, but do not know how to make it true, is there anyone has some suggestion?
Sample code is my favorite.


Sincere thanks

Mentor
SENL1362
Posts: 167
Registered: ‎07-20-2011
Message 2 of 13 (323 Views)

Re: Key Point

12-27-2013 03:36 AM in reply to: HelloWorlddd

Start studying the Selection functions. There are piles of examples.

Search for     ed.GetEntity, ed.GetSelection, ed.Select

 

Valued Contributor
HelloWorlddd
Posts: 87
Registered: ‎05-03-2013
Message 3 of 13 (314 Views)

Re: Key Point

12-27-2013 05:07 AM in reply to: SENL1362

   Yes, I know how to use GetSelection() to get LineObject and the endpoint of LineObject,

 

   But I am thinking of how to let the program know which of endpoints distance more closer to the circle by select the line only, the circle isn’t be selected.

 

   It’s meanI have knew how to access the property of this line, but now my question is there some way will be able to determine which one of the endpoints more distance closer to the circle only by select this line

 

   The program can try or search the near entity of this line, it’s just like a radiolocator..

Mentor
SENL1362
Posts: 167
Registered: ‎07-20-2011
Message 4 of 13 (309 Views)

Re: Key Point

12-27-2013 05:12 AM in reply to: HelloWorlddd
You can select the circles(FilterByLayerOrRadiusOr..) and then calculate the distances from the endpoints to the circles
Valued Contributor
HelloWorlddd
Posts: 87
Registered: ‎05-03-2013
Message 5 of 13 (301 Views)

Re: Key Point

12-27-2013 06:05 AM in reply to: SENL1362

   Uh, I don't want to select anyting except the line, so the question becomes more complicated

   If there is some method can only rely on the selected line, then the program automatically sacnning the near entity of the line just like a radiolocator, and then determine which endpoint is more closer to the specific entity, It’s will be a prefect way…

Mentor
SENL1362
Posts: 167
Registered: ‎07-20-2011
Message 6 of 13 (297 Views)

Re: Key Point

12-27-2013 06:19 AM in reply to: HelloWorlddd

You already knew the selection methodes, so time to show you alternatives:

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable bt = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForRead);

                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                BlockTableRecord ptr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForRead);
                BlockTableRecord mtr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);

                IEnumerable<ObjectId> myEnumerable = mtr.Cast<ObjectId>();
                List<ObjectId> modelObjectIds = myEnumerable.ToList();
                ed.WriteMessage("\n{0} Number of Modelspace entities", modelObjectIDs.Count);

                //All Lines or Polylines
                List<ObjectId> entIDs = modelObjectIds.Where(id => id.ObjectClass.DxfName.ToUpper() == "LINE" || id.ObjectClass.DxfName.ToUpper() == "LWPOLYLINE").ToList<ObjectId>();
                foreach (ObjectId entID in entIDs)
                {
                    Entity theEnt = (Entity)trans.GetObject(entID, OpenMode.ForRead);
                    ed.WriteMessage("\n" + entID.ObjectClass.DxfName + ", " + theEnt.GetType().ToString() + ", " + theEnt.Handle.ToString() + ", " + theEnt.Layer.ToString());
                }

                tr.Commit();
              }

 

Youre circles can be listed using the following:

 List<ObjectId> theCircles = modelObjectIds.Where(id => id.ObjectClass.DxfName.ToUpper() == "CIRCLE" 

Then distances of the endpoints of the selected line to the circle.Centre - the circle.Radius.

 

 

Valued Contributor
HelloWorlddd
Posts: 87
Registered: ‎05-03-2013
Message 7 of 13 (289 Views)

Re: Key Point

12-27-2013 07:31 AM in reply to: SENL1362

   Ah, I think, in fact,  I just need to get the intersection of two objects,

 
   First, select the first object only and then use SelectCrossingPolygon () or other methods get the selectsets, then step though the selectsets ,then get the second specified object, and then get their intersection point


   But, how to get a intersection point between a line with another object, or the intersection point of the extension cord?
   Which class privide a method get the intersection point between object?
   Did you know?

   Very Thanks.

Mentor
SENL1362
Posts: 167
Registered: ‎07-20-2011
Message 8 of 13 (280 Views)

Re: Key Point

12-27-2013 07:43 AM in reply to: HelloWorlddd
Read this Message from this Forum
Measure perpendicular distance between 2 polylines
*Expert Elite*
_gile
Posts: 2,082
Registered: ‎04-29-2006
Message 9 of 13 (271 Views)

Re: Key Point

12-27-2013 09:07 AM in reply to: HelloWorlddd

Have a look in the ObjectARX docs.

The Entity abstract class have a IntesectWith() method.

Gilles Chanteau
Valued Contributor
HelloWorlddd
Posts: 87
Registered: ‎05-03-2013
Message 10 of 13 (259 Views)

Re: Key Point

12-27-2013 11:46 AM in reply to: SENL1362

Thanks~

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.