Moving Objects
Moderators: SDS, support, admin
-
- Posts: 26
- Joined: 23 Feb 2009, 12:30
Moving Objects
Can we move objects with mouse which added by procedure AddScaledDXF?
Re: Moving Objects
Yes, you can.
We recommend to use AddScaledDXFEx for such purposes. It returns TsgDXFInsert object. It contains insert point which is available by Point property. It is necessary to change this point to move the whole XRef.
Here goes a sequence of actions for a common way to solve this task:
We recommend to use AddScaledDXFEx for such purposes. It returns TsgDXFInsert object. It contains insert point which is available by Point property. It is necessary to change this point to move the whole XRef.
Here goes a sequence of actions for a common way to solve this task:
- convert mouse coordinates to CAD point on a drawing - function GetDrawingCoords;
- search an entitiy which contains this CAD point; we recommend to analize Box property of entities whether CAD point is inside;
- change entity's coordinates by the constant value;
- save changes - call TsgDXFImage.CurrentLayout.Converter.Loads(<CAD entity to be moved>).
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 26
- Joined: 23 Feb 2009, 12:30
Re: Moving Objects
var
....
....
....
DXFInsert : TsgDXFInsert;
begin
.....
.....
DXFInsert :=
vGlobalCADFile.AddScaledDXFex(
TsgDXFImage(vCADFiles[k]), // TsgDXFImage object for inserting
'xx', // Name
vPt, // Position in ACAD coords
MakeFPoint(1, 1, 1), // Scale factor
0.0); // Rotation angle (degrees)
------------------------------
It gives Access Violation Error?
....
....
....
DXFInsert : TsgDXFInsert;
begin
.....
.....
DXFInsert :=
vGlobalCADFile.AddScaledDXFex(
TsgDXFImage(vCADFiles[k]), // TsgDXFImage object for inserting
'xx', // Name
vPt, // Position in ACAD coords
MakeFPoint(1, 1, 1), // Scale factor
0.0); // Rotation angle (degrees)
------------------------------
It gives Access Violation Error?
Re: Moving Objects
As we posted on April, 15th (http://www.cadsofttools.com/forum/viewt ... a4a7#p3264), we recommend to use AddScaledDXFEx if it is needed to add the same files as XRef several times:
Sergey.... function AddScaledDXFEx has to be used. If a number of intersection points are more then one, the following algorithm should be used:It is very important: once loaded external file should not be added more then one time using AddScaledDXFEx.
- AddScaledDXFEx returns TsgDXFInsert object, vXRefIns, for instance;
- TsgDXFInsert contains TsgDXFBlock;
- create new TsgDXFInsert object;
- equate vXRefIns.Block to the new TsgDXFInsert.Block;
- set new insert point to TsgDXFInsert.Point (next intersection point);
- add new TsgDXFInsert object to the file contaner.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 26
- Joined: 23 Feb 2009, 12:30
Re: Moving Objects
I want to use TsgDXFInsert which you suggest.
But I ask you to erro "Access Violation".
Is It wrong?
DXFInsert :=
vGlobalCADFile.AddScaledDXFex(
TsgDXFImage(vCADFiles[k]), // TsgDXFImage object for inserting
'xx', // Name
vPt, // Position in ACAD coords
MakeFPoint(1, 1, 1), // Scale factor
0.0); // Rotation angle (degrees)
But I ask you to erro "Access Violation".
Is It wrong?
DXFInsert :=
vGlobalCADFile.AddScaledDXFex(
TsgDXFImage(vCADFiles[k]), // TsgDXFImage object for inserting
'xx', // Name
vPt, // Position in ACAD coords
MakeFPoint(1, 1, 1), // Scale factor
0.0); // Rotation angle (degrees)
Re: Moving Objects
It is wrong because one of TsgDXFImage(vCADFiles[k]) is nil. Please check this array for a correct usage.
Sergey.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 26
- Joined: 23 Feb 2009, 12:30
Re: Moving Objects
TsgDXFImage(vCADFiles[k]) is not nil.
I did not send full code.
I put
...
...
vGlobalCADFile.AddScaledDXFex(
TsgDXFImage(vCADFiles[k]), // TsgDXFImage object for inserting
'xx', // Name
vPt, // Position in ACAD coords
MakeFPoint(1, 1, 1), // Scale factor
0.0); // Rotation angle (degrees)
work well with no error.
I am asking to using TsgDXFInsert.
when I use like it gives "Access Violation Error".
var
....
....
....
DXFInsert : TsgDXFInsert;
begin
.....
.....
DXFInsert :=
vGlobalCADFile.AddScaledDXFex(
TsgDXFImage(vCADFiles[k]), // TsgDXFImage object for inserting
'xx', // Name
vPt, // Position in ACAD coords
MakeFPoint(1, 1, 1), // Scale factor
0.0); // Rotation angle (degrees)
---------------------------
Just adding my working code DXFInsert.
I did not send full code.
I put
...
...
vGlobalCADFile.AddScaledDXFex(
TsgDXFImage(vCADFiles[k]), // TsgDXFImage object for inserting
'xx', // Name
vPt, // Position in ACAD coords
MakeFPoint(1, 1, 1), // Scale factor
0.0); // Rotation angle (degrees)
work well with no error.
I am asking to using TsgDXFInsert.
when I use like it gives "Access Violation Error".
var
....
....
....
DXFInsert : TsgDXFInsert;
begin
.....
.....
DXFInsert :=
vGlobalCADFile.AddScaledDXFex(
TsgDXFImage(vCADFiles[k]), // TsgDXFImage object for inserting
'xx', // Name
vPt, // Position in ACAD coords
MakeFPoint(1, 1, 1), // Scale factor
0.0); // Rotation angle (degrees)
---------------------------
Just adding my working code DXFInsert.
Re: Moving Objects
Hello,
Do you mean that if using:
everything is alright, but if using:
you get AV?
Sergey.
Do you mean that if using:
Code: Select all
vGlobalCADFile.AddScaledDXFEx(...
Code: Select all
DXFInsert := vGlobalCADFile.AddScaledDXFEx(...
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Moving Objects
Is this a question or a confirmation?DarkEternal wrote:Yes?
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 26
- Joined: 23 Feb 2009, 12:30
Re: Moving Objects
When I use Like that
I Get MEssage "ERROR ACCESS VIOLATION"
I am asking why am I get message???
I Get MEssage "ERROR ACCESS VIOLATION"
I am asking why am I get message???
Re: Moving Objects
Hello,
The following code was tested with your CGM files. It works:
Sergey.
The following code was tested with your CGM files. It works:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
vFileList: TList;
vCGMFile: TsgCGMImage;
FImg, vXRefImg: TsgCADImage;
I: Integer;
function AddFileToCrosPoints(vCADContainer: TsgCADImage; vCGMImg: TsgCGMImage):TsgCADImage;
var
I, J, entCnt, K, L: Integer;
ent: TsgDXFEntity;
entPoly, entPolyCross: TsgDXFPolyline;
vCrossPoint: TFPoint;
vXRefIns,vInsert: TsgDXFInsert;
entPolyVertex1, entPolyVertex2, entPolyCrossVertex1, entPolyCrossVertex2: TsgDXFVertex;
begin
vXRefIns := nil;
entCnt := vCADContainer.Converter.Counts[csEntities];
for I := 0 to entCnt - 1 do
begin
ent := vCADContainer.Converter.Sections[csEntities].Entities[I];
if ((ent.EntType = cePolyline) and (ent.Color = clRed)) then
begin
entPoly := TsgDXFPolyline(ent);
for J := I+1 to entCnt - 1 do
begin
ent := vCADContainer.Converter.Sections[csEntities].Entities[J];
if ((ent.EntType = cePolyline) and (ent.Color = clRed)) then
begin
entPolyCross := TsgDXFPolyline(ent);
for K := 0 to entPoly.Count - 2 do
begin
for L := 0 to entPolyCross.Count - 2 do
begin
entPolyVertex1 := TsgDXFVertex(entPoly.Entities[K]);
entPolyVertex2 := TsgDXFVertex(entPoly.Entities[K+1]);
entPolyCrossVertex1 := TsgDXFVertex(entPolyCross.Entities[L]);
entPolyCrossVertex2 := TsgDXFVertex(entPolyCross.Entities[L+1]);
vCrossPoint := MakeFPoint(0,0,0);
if (IsCrossSegmentsPts(entPolyVertex1.Point, entPolyVertex2.Point,
entPolyCrossVertex1.Point, entPolyCrossVertex2.Point,@vCrossPoint)) then
if (vXRefIns = nil) then
vXRefIns := TsgDXFInsert(vCADContainer.AddScaledDXFEx(vCGMImg, vCGMImg.FileName,
vCrossPoint,
MakeFPoint(1,1,1),0.0))
else
begin
vInsert := TsgDXFInsert.Create;
vInsert.Block := vXRefIns.Block;
vInsert.Point := vCrossPoint;
if Assigned(vCADContainer.Converter.OnCreate) then
vCADContainer.Converter.OnCreate(vInsert);
vCADContainer.Converter.Loads(vInsert);
vCADContainer.CurrentLayout.AddEntity(vInsert);
end;
end;
end;
end;
end;
end;
end;
if vInsert <> nil then
Result := TsgCADImage(vInsert.Block.Xref.CADImage)
else
Result := nil;
end;
begin
if (FsgPaintBox <> nil) and (FsgPaintBox.Picture.Graphic is TsgCADImage) then
FImg := TsgCADImage(FsgPaintBox.Picture.Graphic)
else
Exit;
vFileList := TList.Create;
vCGMFile := TsgCGMImage.Create;
vCGMFile.LoadFromFile('c:\62982.cgm');
vFileList.Add(vCGMFile);
vCGMFile := TsgCGMImage.Create;
vCGMFile.LoadFromFile('c:\62989.cgm');
vFileList.Add(vCGMFile);
vCGMFile := TsgCGMImage.Create;
vCGMFile.LoadFromFile('c:\62995.cgm');
vFileList.Add(vCGMFile);
vCGMFile := TsgCGMImage.Create;
vCGMFile.LoadFromFile('c:\629990.cgm');
vFileList.Add(vCGMFile);
//===
vXRefImg := TsgCADImage(AddFileToCrosPoints(FImg,vFileList[0]));
for I := 1 to vFileList.Count - 1 do
begin
if vXRefImg <> nil then
vXRefImg := TsgCADImage(AddFileToCrosPoints(vXRefImg, vFileList[I]));
end;
FImg.GetExtents;
vFileList.Free;
end;
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 26
- Joined: 23 Feb 2009, 12:30
Re: Moving Objects
Now I can find my file with that code :
TsgDXFInsert(TsgDXFImage(sgPaintBox.Picture.Graphic).Converter.Sections[csEntities].Entities[1]).Point := MakeFPoint(100,100,0);
But nothing changes on sgPaintBox;
I try sgPaintBox.Refresh Repaint Update .But nothing changed.
If I can change point with this code, I can do moving objects
What do I need for refresh?
TsgDXFInsert(TsgDXFImage(sgPaintBox.Picture.Graphic).Converter.Sections[csEntities].Entities[1]).Point := MakeFPoint(100,100,0);
But nothing changes on sgPaintBox;
I try sgPaintBox.Refresh Repaint Update .But nothing changed.
If I can change point with this code, I can do moving objects
What do I need for refresh?
Re: Moving Objects
It is necessary to call
Sergey.
Code: Select all
TsgDXFImage.GetExtents;
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 26
- Joined: 23 Feb 2009, 12:30
Re: Moving Objects
But I use
var
sgPaintBox: TsgDrawingNavigator;
So I try
TsgDXFImage(sgPaintBox.Picture.Graphic).GetExtents;
But again nothing changed?
var
sgPaintBox: TsgDrawingNavigator;
So I try
TsgDXFImage(sgPaintBox.Picture.Graphic).GetExtents;
But again nothing changed?