select and move a line's point1

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

select and move a line's point1

Post by Khyati » 04 Apr 2011, 11:27

5 lines are drawn by user on CAD editor control's picture box.
Now user selects one line. (say line 1)

I want to delete that line(line 1) and select its next line(line 2).

I can use cadEditorControl1.DeleteSelectedEntities for deleting.
1) But how to select the next line(line 2) in program?

2) After selection of that line, i want to change its position. How can i move its point1(line2.Point1) to next lines's point (line3.Point)?

These are very basic requirement for our application. Please do reply.
We are struggling from few months to stable on a CAD software. I wish i can set on CAD Import.Net.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: select and move a line's point1

Post by support » 04 Apr 2011, 18:27

Hello Khyati.
You can select entities from code, using CADEditorControl.Image.SelectedEntities.Add(required_entity). Entities of the current layout can be found in CADEditorControl.Image.Converter.Entities collection. Entities drawn by user will be placed to this collection with increased indexes. For example, user will draw 5 lines on empty CADImage. Converter.Entities collection will receive 5 members with indexes from 0 to 4. When you delete first line (with index 0) remained lines' indexes will be reduced to 1

Code: Select all

CADEntityCollection ents = this.cadEditorControl1.Image.Converter.Entities;
cadEditorControl1.Image.SelectedEntities.Add(ents[0]);
ents[0].Selected = true;
((CADLine)ents[0]).Point1 = ((CADLine)ents[1]).Point;
ents[0].Loaded(this.cadEditorControl.Image.Converter);
cadEditorControl1.Invalidate();
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

Re: select and move a line's point1

Post by Khyati » 05 Apr 2011, 07:51

Thanks!

As i want to make it programatically and general(not customize), I used handle to find out next entity's handle and then did other action.

Well, now after delete a line, handles to all entities remain same.
in logic, if i use handle "i+1", it is possible that entity with "i+1" handle is already deleted. ("i" is handle of selected entity)

1) is there any method to refresh handles as per new drawing or available entities?
2) how can i check from handle whether that entity exists or not?

Both above questions are related to program, not with GUI, please.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: select and move a line's point1

Post by support » 05 Apr 2011, 10:55

Hello.
Using handles to access entities a bit different. Handle is unique entity identifier and it won't be modified by any methods applied to entities collection. Values of the handles of newly created entities doesn't differs to some constant like 1. So any refreshing isn't necessary and you need store handles somewhere to access each of five lines. CADEntityCollection.IndexOf method can be used to check if entity exists in checked collection. The method parameter must be existing entity. Returned value is index of entity in collection. If it less then zero then entity with such handle doesn't exist in collection.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

Re: select and move a line's point1

Post by Khyati » 06 Apr 2011, 09:43

1) how to know total no of entities (any line, point, circle etc.) are drawn by user till now?
2) is there any count available which gets updated after deletion of different entities?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: select and move a line's point1

Post by support » 06 Apr 2011, 10:25

Hello Khyati.
CAD Import .NET doesn't provide any tools to specify how many entities was drawn by user. As the developer you can implement such functionality in your application by using special field/property.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

Re: select and move a line's point1

Post by Khyati » 06 Apr 2011, 12:11

Thanks!

Post Reply