Insert Polyline into given Block
Moderators: SDS, support, admin
Insert Polyline into given Block
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:
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);
Re: Insert Polyline into given Block
Hello!
First of all can you please specify the task you have.
Sergey.
First of all can you please specify the task you have.
- Get selected Insert.
- Get a block from the selected Insert.
- Find all polylines with 4 vertexes in the block from the selected Insert.
- Delete all polylines with 4 vertexes in the block from the selected Insert.
- Create two new polylines with 3 vertexes basing on the deleted polylines with 4 vertexes in the block from the selected Insert.
- Add two created polylines with 3 vertexes based on the deleted polylines with 4 vertexes in the block from the selected Insert.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Insert Polyline into given Block
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 ?
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 ?
Re: Insert Polyline into given Block
Hello!
When an entity must be added we recommend the following way:
When adding an entity in a block inserted in the image we recommend to use the following way:
Sergey.
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);
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);
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support