Moving Objects
Posted: 20 Apr 2009, 10:01
Can we move objects with mouse which added by procedure AddScaledDXF?
CADSoftTools - AutoCAD DWG DXF HPGL (PLT) SVG CGM STEP IGES STL SAT viewers, converters and developer tools. Delphi and C# source code.
https://cadsofttools.com/forum/
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.
Code: Select all
vGlobalCADFile.AddScaledDXFEx(...
Code: Select all
DXFInsert := vGlobalCADFile.AddScaledDXFEx(...
Is this a question or a confirmation?DarkEternal wrote:Yes?
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;
Code: Select all
TsgDXFImage.GetExtents;