How to change the entity with CADImportVCL?

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

Moderators: SDS, support, admin

Post Reply
hustwjz
Posts: 9
Joined: 30 Mar 2006, 05:48
Location: China

How to change the entity with CADImportVCL?

Post by hustwjz » 30 Mar 2006, 06:02

I hope to change the property of entities, but how?
I found that I can change the content of TEXT easily, but it' very hard to change the content of MTEXT.
And, I don't know how to change the content of dimmension and ATTDEF.
My code is as followings:

Code: Select all

<b>function</b> TMainForm.CopyMText(AMText: TsgDXFMText): TsgDXFMText;
<b>var</b>
  NewText: TsgDXFMText;
<b>begin</b>
  NewText := TsgDXFMText.Create;

NewText.Align 	        :=	AMText.Align;
NewText.Height 	        :=	AMText.Height;
NewText.Point           :=      AMText.Point;
NewText.Point1 	        :=	AMText.Point1 ;
NewText.RectHeight 	:=	AMText.RectHeight ;
NewText.RectWidth 	:=	AMText.RectWidth ;
NewText.Style 	        :=	AMText.Style ;
NewText.Text 	        :=	AMText.Text ;
NewText.Angle 	        :=	AMText.Angle ;
//NewText.Block 	:=	AMText.Block ;      Must be marked  or runtime error
NewText.Box 	        :=	AMText.Box ;;
NewText.Color 	        :=	AMText.Color ;
NewText.Enters 	        :=	AMText.Enters ;
NewText.Extrusion 	:=	AMText.Extrusion ;
NewText.Scale 	        :=	AMText.Scale ;
//NewText.Owner 	:=	AMText.Owner ;   NO
NewText.Complex 	:=	AMText.Complex ;
//NewText.Converter 	:=	AMText.Converter ; NO
//NewText.Count 	:=	AMText.Count ;       NO
NewText.Box 	        :=	AMText.Box ;
//NewText.Entities 	:=	AMText.Entities ;      NO
NewText.Handle 	        :=	AMText.Handle ;
NewText.Layer 	        :=	AMText.Layer ;
NewText.LineTypeScale 	:=	AMText.LineTypeScale ;
NewText.PaperSpace 	:=	AMText.PaperSpace ;
//NewText.SrcStart 	:=	AMText.SrcStart ;
//NewText.SrcEnd 	:=	AMText.SrcEnd ;
NewText.Visible 	:=	AMText.Visible ;
NewText.Visibility 	:=	AMText.Visibility ;
{  CopyMemory(@NewText, @AMText, sizeof(AMText));
  NewText.Block := <b>nil</b>;
  NewText.SrcStart := <b>nil</b>;
  NewText.SrcEnd   := <b>nil</b>;}
  NewText.Text := 'MText by wjz';
  Result := NewText;
<b>end</b>;
///////////////////////////////////////////////////////////////////
<b>if</b> (AEnt <b>is</b> TsgDXFMText) <b>then
    begin</b>
      AMText := AEnt <b>as</b> TsgDXFMText;
      NewText := CopyMText(AMText);

      EntList.DeleteEntity(AMText, TRUE);

      EntList.Sections[csEntities].AddEntity(NewText);
      <b>if</b> Assigned(EntList.OnCreate) <b>then</b>
        EntList.OnCreate(NewText);
      EntList.Loads(NewText);
    <b>end
    else if</b> (AEnt <b>is</b> TsgDXFText) <b>then
    begin</b>
      AText := AEnt <b>as</b> TsgDXFText;
      AText.Text := 'Text Changed';
    <b>end</b>;
  <b>end</b>;
  DwgLoader.Refresh;
My question are:
1. Why can't I use CopyMemory to copy the properties of entities?
2. Why can only I change the content of MText by deleting and adding MText?
3. How can I change the content of dimmension?

I am waiting for your answer.

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

Post by support » 30 Mar 2006, 17:37

Hello,

>1. Why can't I use CopyMemory to copy the properties of entities?
This way is impossible for objects in common case. There is a high probability of double destroying the same object. Properties of the object may contain references to objects of other classes . Besides there may be lists which can't be copied by CopyMemory .

>2. Why can only I change the content of MText by deleting and adding MText?

When changing some properties: text, position, color etc. it is necessary to call Converter.Loads(NewText) method.
.It is 'EntList.Loads(NewText);' in the described example above.

>3. How can I change the content of dimmension?

The content of dimension lays in the block to which dimension references. Block contains entities: LINEs, SOLID (dim arrows), TEXT (MTEXT).
In order to change the dimension's contents you shoud change these entities.

Sergey.


please post questions to the forum or write to support@cadsofttools.com

hustwjz
Posts: 9
Joined: 30 Mar 2006, 05:48
Location: China

Post by hustwjz » 03 Apr 2006, 12:36

Is there easy way to change the properties?
Since CopyMemory doesn't work, can you provide a function with which we can copy entities easily?
Such as
function CopyPropery(EntTarget, EntSource: TsgDXFEntity): Boolean;

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

Post by support » 03 Apr 2006, 14:05

Hello,

We can add this functionality. It demands about a month for all entities. If you need some specific entities it will be done faster.

Sergey.

please post questions to the forum or write to support@cadsofttools.com

hustwjz
Posts: 9
Joined: 30 Mar 2006, 05:48
Location: China

Post by hustwjz » 04 Apr 2006, 08:50

We need to handle three kind of entities currently
MTEXT, ATTDEF, DIMMENSION(including the block it refers to)

Thought that I found a powerfull CAD tool, keep on testing.....

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

Post by support » 22 Jun 2006, 16:13

Hello

We have released CADImportVCL v.5.2.5 (available on: http://www.cadsofttools.com/download/cadimportvcl.zip). Demo application <b>Add New Entity</b> demonstrates how to copy entities. You can find it in the ..\cadimportvcl\Delphi\Demos\Add new entities\.. folder.
On the following page you can find the list of entities which supports AssignEntity() method: http://www.soft-gold.ru/forum/topic.asp?TOPIC_ID=272

Sergey.

please post questions to the forum or write to support@cadsofttools.com

Post Reply