Create a Polymesh
Moderators: SDS, support, admin
-
- Posts: 54
- Joined: 14 Mar 2015, 22:33
Create a Polymesh
The library can read dwg files that contain Polymesh, the relevant question is, is it possible to create Polymesh objects using code? IF the answer is affirmative, you could show a simple code on how to do it.
Thank you.
Thank you.
Re: Create a Polymesh
Hello,
CAD VCL allows to create Polyface Mesh objects from code. A polyface mesh is represented in DWG/DXF files as a variant of a polyline entity, so you should use a TsgDXFPolyline class for creating a polymesh.
The code example below shows how to create a polyface mesh using the TsgDXFPolyline and TsgDXFVertex classes.
Mikhail
CAD VCL allows to create Polyface Mesh objects from code. A polyface mesh is represented in DWG/DXF files as a variant of a polyline entity, so you should use a TsgDXFPolyline class for creating a polymesh.
The code example below shows how to create a polyface mesh using the TsgDXFPolyline and TsgDXFVertex classes.
Code: Select all
uses
..., CADImage, DXFConv, sgConsts;
implementation
{$R *.dfm}
procedure AddEntityToImage(ATargetImage: TsgCADImage; AEntity: TsgDXFEntity);
begin
if not Assigned(ATargetImage) then Exit;
ATargetImage.CurrentLayout.AddEntity(AEntity);
if Assigned(ATargetImage.Converter.OnCreate) then
ATargetImage.Converter.OnCreate(AEntity);
ATargetImage.Converter.Loads(AEntity);
ATargetImage.GetExtents;
end;
procedure Add3DVertex(ADXFPolyline: TsgDXFPolyline; const AX, AY, AZ: TsgFloat);
var
vDXFVertex: TsgDXFVertex;
begin
vDXFVertex := TsgDXFVertex.Create;
vDXFVertex.Point := MakeFPoint(AX, AY, AZ);
ADXFPolyline.AddEntity(vDXFVertex);
end;
procedure AddPolyfaceByVertices(ADXFPolyline: TsgDXFPolyline; const I1, I2, I3, I4: Integer);
var
vDXFVertex: TsgDXFVertex;
begin
vDXFVertex := TsgDXFVertex.Create;
vDXFVertex.Flags := 128; // Polyface mesh vertex
vDXFVertex.PolyFaceVertexIndex1 := I1;
vDXFVertex.PolyFaceVertexIndex2 := I2;
vDXFVertex.PolyFaceVertexIndex3 := I3;
vDXFVertex.PolyFaceVertexIndex4 := I4;
ADXFPolyline.AddEntity(vDXFVertex);
end;
procedure CreatePolyfaceMesh(ATargetImage: TsgCADImage);
var
vDXFPolyline: TsgDXFPolyline;
begin
vDXFPolyline := TsgDXFPolyline.Create;
vDXFPolyline.Flags := 64; // The polyline is a polyface mesh
vDXFPolyline.MeshM := 10; // The number of vertices
vDXFPolyline.MeshN := 3; // The number of polyfaces
// Add 10 vertices
Add3DVertex(vDXFPolyline, 157, 177, 0);
Add3DVertex(vDXFPolyline, 190, 196, 0);
Add3DVertex(vDXFPolyline, 223, 176, 0);
Add3DVertex(vDXFPolyline, 209, 203, 0);
Add3DVertex(vDXFPolyline, 234, 218, 0);
Add3DVertex(vDXFPolyline, 201, 218, 0);
Add3DVertex(vDXFPolyline, 190, 244, 0);
Add3DVertex(vDXFPolyline, 179, 219, 0);
Add3DVertex(vDXFPolyline, 148, 219, 0);
Add3DVertex(vDXFPolyline, 172, 204, 0);
// Add 3 triangular polyfaces
AddPolyfaceByVertices(vDXFPolyline, 1, 5, 8, 0);
AddPolyfaceByVertices(vDXFPolyline, 3, 7, 10, 0);
AddPolyfaceByVertices(vDXFPolyline, 9, 8, 10, 0);
// Set a color for the polyface mesh
vDXFPolyline.Color := clRed;
AddEntityToImage(ATargetImage, vDXFPolyline);
end;
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 54
- Joined: 14 Mar 2015, 22:33
Re: Create a Polymesh
Tanks!!! Perfect.
Another thing, when you are ready with version 13?
Felipe
Another thing, when you are ready with version 13?
Felipe
Re: Create a Polymesh
Felipe,
The next major version is currently at the testing stage, so for now we cannot give you any information about the release date.
Mikhail
The next major version is currently at the testing stage, so for now we cannot give you any information about the release date.
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support