Insert Polyline into given Block

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
mike32m
Posts: 13
Joined: 17 Jun 2008, 16:06

Insert Polyline into given Block

Post by mike32m » 01 Aug 2008, 09:21

I have two problems in my 3D-project:
I must change every Polyline with 4 Vertex into two Polylines with 3 Vertex. All polylines are in one block which is inserted into cadImage by an INSERT-Object on a defined position.
The cadImage can also have other blocks, without changing and the Block must be selected by the treeview-element (select by the INSERT is working ... SelectedEntityKey)
Now the actually code sample:

Code: Select all

foreach (CADEntity ce in cadImage.Layouts[0].Entities.AllValues) {
  if (ce.EntType == EntityType.Insert) {
    CADInsert ci = ce as CADInsert;
    if (ci.KeyEnt == SelectedEntityKey) {
      foreach (CADBlock cb in ci.Converter.Blocks.AllValues) {
         foreach (CADEntity cf in cb.Entities.AllValues) {
             if (cf.Entities.Count==4) {
                CADVertex v1 = cf.Entities[0] as CADVertex;
                CADVertex v2 = cf.Entities[1] as CADVertex;
                CADVertex v3 = cf.Entities[2] as CADVertex;
                CADVertex v4 = cf.Entities[3] as CADVertex;
                Color col = cf.Color;

                cb.Entities.Remove(cf.KeyEnt);		// old polyline with 4 vertex remove

                CADPolyLine cp1 = new CADPolyLine();					
                cp1.Closed = true;
                cp1.Color = col;                                        <=== must be the default color (from Layer or Layout)
                cp1.AddEntity(v1);	cp1.AddEntity(v2);	cp1.AddEntity(v3);

                //CADPolyLine cp2 = (... as cp1)

                cb.Entities.Add(cp1);              // add new polylines to the actually block
                cb.Entities.Add(cp2);

                cp1.Loaded(cadImage.Converter);                 <===   this section is not correct, but how must it be correctly
                cadImage.Converter.on.OnCreate(cp1);	                                
                cadImage.CurrentLayout.Entities.Add(cp1);


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

Re: Insert Polyline into given Block

Post by support » 01 Aug 2008, 09:47

Hello!

First of all can you please specify the task you have.
  1. Get selected Insert.
  2. Get a block from the selected Insert.
  3. Find all polylines with 4 vertexes in the block from the selected Insert.
  4. Delete all polylines with 4 vertexes in the block from the selected Insert.
  5. Create two new polylines with 3 vertexes basing on the deleted polylines with 4 vertexes in the block from the selected Insert.
  6. Add two created polylines with 3 vertexes based on the deleted polylines with 4 vertexes in the block from the selected Insert.
Is everything correct?

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

mike32m
Posts: 13
Joined: 17 Jun 2008, 16:06

Re: Insert Polyline into given Block

Post by mike32m » 01 Aug 2008, 12:16

yes, so it's correct, but the end (inserting the new elements i have problems with the correct methodes)
it will be helpfull for a more description of these methodes. The helpfile is not so good, not so many descriptions for methodes.
other question: Give it a german helpfile ?

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

Re: Insert Polyline into given Block

Post by support » 04 Aug 2008, 13:33

Hello!

When an entity must be added we recommend the following way:

Code: Select all

CADEntity ent = new CADEntity();
//...
//initialize properities of ent
//...
ent.Loaded(CADImport.CADImage.Converter);			
CADImport.CADImage.Converter.OnCreate(ent);
CADImport.CADImage.CurrentLayout.Entities.Add(ent);	
When adding an entity in a block inserted in the image we recommend to use the following way:

Code: Select all

CADEntity ent = new CADEntity();
//...
//initialize properities of ent
//...
ent.Loaded(CADImport.CADImage.Converter);	
CADImport.CADImage.Converter.OnCreate(ent);					
													
CADInsert.Block.Entities.Add(ent);
						
CADInsert.Block.Loaded(this.cadImage.Converter);
CADInsert.Loaded(this.cadImage.Converter);
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply