How to create a BLOCK
Moderators: SDS, support, admin
How to create a BLOCK
Hi,
I need an example on how to create and use a block.
Is there any ?
Thanks
Aby
I need an example on how to create and use a block.
Is there any ?
Thanks
Aby
Re: How to create a BLOCK
Hello aby.
Creation the block is the similar to any common entity. The following code sample shows adding block referense to CADImage structure, you can implement it into AddNewEntities demo code:
Alexander.
Creation the block is the similar to any common entity. The following code sample shows adding block referense to CADImage structure, you can implement it into AddNewEntities demo code:
Code: Select all
void Add_Entity(TsgDXFConverter * AConverter, TConvSection sect, TsgDXFEntity * AEnt)
{
AConverter->Sections[sect]->AddEntity(AEnt);
if (AConverter->OnCreate)
AConverter->OnCreate(AEnt);
AConverter->Loads(AEnt);
}
void __fastcall TfmMain::btnNewClick(TObject *Sender)
{
TsgDXFEntity *Ent = NULL;
TsgCADImage *Im;
TsgDXFBlock *blck;
TsgDXFInsert *ins;
if (!sgPaintBox->Empty())
if (sgPaintBox->Picture->Graphic->InheritsFrom(__classid(TsgCADImage)))
{
Im = dynamic_cast<TsgCADImage *>(sgPaintBox->Picture->Graphic);
Ent = GetEntity(Im);
if (Ent != NULL)
{
TsgDXFBlock *blck = new TsgDXFBlock();
blck->Name = "NAME1";
TsgDXFInsert *ins = new TsgDXFInsert();
ins->Block = blck;
//AddEntity(Im->Converter, Ent);
blck->AddEntity(Ent);
Add_Entity(Im->Converter, csBlocks, blck);
Add_Entity(Im->Converter, csEntities, ins);
Im->GetExtents();
FLastAdded = Ent;
}
sgPaintBox->Refresh();
}
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support