How to change the entity with CADImportVCL?
Moderators: SDS, support, admin
How to change the entity with CADImportVCL?
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:
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.
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;
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.
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
>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
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
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
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
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