How to create a BLOCK

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
aby
Posts: 81
Joined: 21 May 2007, 13:02
Location: Turkey

How to create a BLOCK

Post by aby » 26 Oct 2010, 18:18

Hi,

I need an example on how to create and use a block.

Is there any ?

Thanks

Aby

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

Re: How to create a BLOCK

Post by support » 29 Oct 2010, 16:32

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:

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();
	}
}
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply