全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:829
推到 Plurk!
推到 Facebook!

4D-CAD Urban Planning

 
conundrum
尊榮會員


發表:893
回覆:1272
積分:643
註冊:2004-01-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-05-21 00:11:40 IP:218.175.xxx.xxx 未訂閱
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=63151    4D-CAD Urban Planning     http://www.visual-engineering.com/cadvprog.html Sample Delphi source code for extracting Cadvance  
http://www.visual-engineering.com/delphicadvanceexample1.html        unit VPSExport;    interface    uses
  SysUtils,
  Windows,
  Classes,
  Dialogs,
  Cditypes,
  Cdiprocs,
  Cdiprocs3D,
  Cdiconst,
  DateUtils,
  Variants,
  AdoDb,
  Db,
  DbTables,
  CadvanceUtils,
  LayerUtilities;      procedure ExportSubModel;stdcall;
  procedure SaveSubmodelLayers(const submodel:string; const revision:string ; const ConnString:string);
  procedure SaveMemberData(const basepoint:CDI_DDD_POINT; const master_segid:CDI_SEGID; const AutoObjectNumber:longint;const ADODataSet:TADODataset);
  function ClockWise(var xp:array of World;var yp:array of World; lvertex:smallint):boolean;    implementation    function ClockWise(var xp:array of World;var yp:array of World; lvertex:smallint):boolean;
var
  area:double;
  vertex:smallint;
  vx1:double;
  vx2:double;
  vy1:double;
  vy2:double;    begin      area:=0;
  for vertex:= 0 to lvertex-1 do
    begin
      vx1:=xp[vertex];
      vx2:=xp[vertex 1];
      vy1:=yp[vertex];
      vy2:=yp[vertex 1];
      area:=area   vx1 * vy2 - vx2 * vy1;
    end;      if area<0 then
    begin
      result:=true;
    end
  else
    begin
      result:=false;
    end    end;    procedure ExportSubModel;stdcall;
var
  SaveDialog1:TSaveDialog;
  i_ret:smallint;
  WorldCube:CDI_3DWORLD_CUBE;
  line_bufferextents:CDI_3DWORLD_CUBE;
  object1:CDI_OSL_OBJECT;
  text_buffer:CDI_TEXT_BUFFER;
  line_buffer:CDI_LINESET_BUFFER;
  circle_buffer:CDI_CIRCLE_BUFFER;
  arc_buffer:CDI_ARC_BUFFER;
  line3d_buffer:CDI_3DLINESET_BUFFER;
  face_buffer:CDI_3DFACE_BUFFER;
  symbol_buffer:CDI_SYM_GRP_BUFFER;
  symbol3d_buffer:CDI_3DSYM_GRP_BUFFER;
  seg_id:CDI_SEGID;
  pnt1:CDI_DDD_POINT;
  pnt2:CDI_DDD_POINT;
  obj_type:smallint;
  layer:smallint;
  uniqueId:longint;
  numb:smallint;
  vertex:smallint;
  lvertex:smallint;
  op:smallint;
  textdata:string;
  BlockName:string;
  textlen:smallint;
  lname:string;
  count:longint;      DatabaseFileName:string;
  ADODataSet1:TADODataset;
  ADODataSet2:TADODataset;
  ADODataSet3:TADODataset;
  ADODataSet4:TADODataset;
  ADOConnection1:TADOConnection;
  VertexArray:array of variant;
  ConnString:string;
  VertexString:string;
  submodelname:string;
  revision:string;
  CoordData:string;
  xp:array[0..200] of WORLD;
  yp:array[0..200] of WORLD;
  zp:array[0..200] of WORLD;
  l_osl:longint;
  textcount:smallint;
  object2:CDI_OSL_OBJECT;
  obj_type2:smallint;
  layer2:smallint;
  area:double;
  description:string;
  BuildingHeight:double;
  BuildingColor:longint;
  notClockwise:boolean;
  extrude:boolean;    begin      submodelname:='owners';
  description:='building ownership';
  revision:='00';
  extrude:=true;      submodelname:='terrain';
  description:='terrain model';
  revision:='00';      SaveDialog1:=TSaveDialog.create(nil);
  SaveDialog1.DefaultExt:='vps';
  SaveDialog1.FileName:='*.vps';
  SaveDialog1.Execute;
  if (SaveDialog1.FileName<>'') or (SaveDialog1.FileName<>'*.vps') then
    begin
      DatabaseFileName:=SaveDialog1.FileName;
    end
  else
    begin
      SaveDialog1.Free;
      exit;
    end;      WorldCube.ext_x1:=999999999;
  WorldCube.ext_y1:=999999999;
  WorldCube.ext_z1:=999999999;
  WorldCube.ext_x2:=-999999999;
  WorldCube.ext_y2:=-999999999;
  WorldCube.ext_z2:=-999999999;      ConnString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' 
    DatabaseFileName  ';Mode=ReadWrite|Share Deny None;Persist Security Info=False';      ADOConnection1:=TADOConnection.create(nil);
  with ADOConnection1 do begin
    ConnectionString:=ConnString;
    ADOConnection1.Open;
  end;      //ADOConnection1.execute('DELETE * FROM pEntities');
  ADOConnection1.execute('DELETE * FROM pEntities AS A WHERE EXISTS (SELECT * FROM pObjects WHERE A.AutoObjectNumber = pObjects.AutoObjectNumber AND pObjects.Sub_Mod=''' submodelname ''')');
  ADOConnection1.execute('DELETE * FROM [pObjects] WHERE [sub_mod]=''' submodelname '''');
  ADOConnection1.execute('DELETE * FROM [pLayers] WHERE [sub_mod]=''' submodelname '''');
  ADOConnection1.execute('DELETE * FROM [pSubModels] WHERE [sub_mod]=''' submodelname '''');      ADOConnection1.Close;
  ADOConnection1.Free;      count:=CdiOslCount(0);
  if (count=0) then
    begin
      SaveDialog1.Free;
      exit;
    end;      SaveSubmodelLayers(submodelname, revision, ConnString);      ADODataSet2:=TADODataset.create(nil);
  with ADODataSet2 do begin
  ADODataSet2.CommandText:='SELECT * FROM [pObjects]';
    ConnectionString:=ConnString;
    Open;
  end;      ADODataSet3:=TADODataset.create(nil);
  with ADODataSet3 do begin
  ADODataSet3.CommandText:='SELECT * FROM [pEntities]';
    ConnectionString:=ConnString;
    Open;
  end;      for numb:=0 to count-1 do
    begin          i_ret:=CdiOslItem(0, numb, object1);
      i_ret:=CdiObjType(object1.sid, obj_type, layer);
      uniqueId:=0;          case obj_type of
        CDI_TEXT:
          begin
            i_ret:=CdiObjInfo(object1.sid, @text_buffer);
            textlen:=text_buffer.length;
            i_ret:=CdiGetUniqueId(object1.sid, uniqueId);
            lname:=LayerName(text_buffer.layer);
            line_bufferextents.ext_x1:=text_buffer.extents.left;
            line_bufferextents.ext_x2:=text_buffer.extents.right;
            line_bufferextents.ext_y1:=text_buffer.extents.bottom;
            line_bufferextents.ext_y2:=text_buffer.extents.top;
            line_bufferextents.ext_z1:=0;
            line_bufferextents.ext_z2:=0;                textdata:=text_buffer.string_buffer;
            VertexArray:=nil;
            with ADODataset2 do
              begin
                Append;
                FieldValues['sub_mod']:=submodelname;
                FieldValues['layer']:=LayerName(text_buffer.layer);
                FieldValues['rev']:=revision;
                FieldValues['grp_owner']:=inttostr(uniqueId);
                FieldValues['obj_type']:='D';
                FieldValues['xmin']:=DimtoSingle(line_bufferextents.ext_x1);
                FieldValues['ymin']:=DimtoSingle(line_bufferextents.ext_y1);
                FieldValues['zmin']:=DimtoSingle(line_bufferextents.ext_z1);
                FieldValues['xmax']:=DimtoSingle(line_bufferextents.ext_x2);
                FieldValues['ymax']:=DimtoSingle(line_bufferextents.ext_y2);
                FieldValues['zmax']:=DimtoSingle(line_bufferextents.ext_z2);
                Post;
              end;
              ADODataset2.Last;                  pnt1.x:=text_buffer.position.x;
              pnt1.y:=text_buffer.position.y;
              pnt1.z:=0;                  with ADODataset3 do
                begin
                  Append;
                  FieldValues['AutoObjectNumber']:=ADODataset2.FieldValues['AutoObjectNumber'];
                  FieldValues['Entity_Handle']:=inttostr(uniqueId);
                  FieldValues['Orig_Prim_type']:='TEXT';
                  FieldValues['color']:=ColorValue(text_buffer.color);
                  FieldValues['mark']:='-';
                  FieldValues['mat_prop_Id']:='-';
                  FieldValues['geom_type']:='TEXT';
                  FieldValues['data']:='1' chr(9) 
                                  floattostr(text_buffer.rotation) chr(9) 
                                  '1.0' chr(9) 
                                  floattostr(DimtoSingle(text_buffer.height)) chr(9) 
                                  'F' chr(9) 
                                  'CADTEXT' chr(9) 
                                  floattostr(DimtoSingle(pnt1.x)) chr(9) 
                                  floattostr(DimtoSingle(pnt1.y)) chr(9) 
                                  floattostr(DimtoSingle(pnt1.z)) chr(9) 
                                  textdata chr(9);                      Post;
                end;              end;            CDI_LINESET:
          begin
            BuildingHeight:=0.0;
            i_ret:=CdiObjInfo(object1.sid, @line_buffer);
            i_ret:=CdiEditDraw(object1.sid, 1);
            i_ret:=CdiGetUniqueId(object1.sid, uniqueId);                lname:=LayerName(line_buffer.layer);
            line_bufferextents.ext_x1:=line_buffer.extents.left;
            line_bufferextents.ext_x2:=line_buffer.extents.right;
            line_bufferextents.ext_y1:=line_buffer.extents.bottom;
            line_bufferextents.ext_y2:=line_buffer.extents.top;
            line_bufferextents.ext_z1:=0;
            line_bufferextents.ext_z2:=0;                CalculateMax3DExtents(line_bufferextents, WorldCube);
            lvertex:=line_buffer.number_of_elements;                For vertex:= 0 To lvertex do
              begin
                i_ret:= CdiObjInfoxy(pnt1, op, vertex, line_buffer);
                xp[vertex]:= pnt1.x;
                yp[vertex]:= pnt1.y;
                zp[vertex]:= 0;
              end;
            notClockwise:=Clockwise(xp,yp,lvertex);                If notClockwise=false then
              begin
                For vertex:=lvertex downto 0 do
                  begin
                    i_ret:= CdiObjInfoxy(pnt1, op, vertex, line_buffer);
                    xp[lvertex-vertex]:= pnt1.x;
                    yp[lvertex-vertex]:= pnt1.y;
                    zp[lvertex-vertex]:= 0;
                  end;
              end;                textdata:=inttostr(uniqueId);
            l_osl:= CdiCreateLocalOsl(CDI_OBJECT_COLOR, 0, CDI_REDRAW_OSL);
            i_ret:= CdiSelectbyPolygon(l_osl, '', CDI_PARTIAL_FENCE, CDI_TRUE, CDI_TRUE, @xp, @yp, lvertex, CDI_SEL2D_TEXT);
            If (i_ret=CDI_ABORT) Or (i_ret=CDI_ERROR) Then
              begin
              end;                  if CdiOslCount(l_osl)>0 then
                begin
                  for textcount:=0 to CdiOslCount(l_osl)-1 do
                    begin
                      i_ret:=CdiOslItem(l_osl, textcount, object2);
                      i_ret:=CdiGetUniqueId(object2.sid, uniqueId);
                      i_ret:=CdiObjType(object2.sid, obj_type2, layer2);                          if (obj_type2=CDI_TEXT) then
                        begin
                          i_ret:=CdiObjInfo(object2.sid, @text_buffer);
                          //textpnt:=text_buffer.position;
                          textlen:=text_buffer.length;
                          textdata:=text_buffer.string_buffer;                              if extrude=true then
                            begin
                              ADODataSet4:=TADODataset.create(nil);
                              with ADODataSet4 do begin
                               ADODataSet4.CommandText:='SELECT * FROM [building information] WHERE [lot name]=''' textdata '''';
                                ConnectionString:=ConnString;
                                Open;
                                BuildingHeight:=0.0;
                                  if FieldValues['height']<>null then
                                   begin
                                      BuildingHeight:=FieldValues['height'];
                                      BuildingColor:=FieldValues['color'];
                                   end;
                              end; //with                                  ADODataSet4.Close;
                              ADODataSet4.Free;
                            end; //extrude=true                            end; //(obj_type2=CDI_TEXT)                        end ; //textcount                    end; //CdiOslCount(l_osl)>0                i_ret:=CdiFreeLocalOsl(l_osl);                VertexString:=inttostr(lvertex*3*2);
            For vertex:= 1 To lvertex do
              begin
                VertexString:=VertexString chr(9) FormatDimString(xp[vertex-1]) chr(9) FormatDimString(yp[vertex-1]) chr(9) FormatDimString(zp[vertex-1]);
                VertexString:=VertexString chr(9) FormatDimString(xp[vertex]) chr(9) FormatDimString(yp[vertex]) chr(9) FormatDimString(zp[vertex]);
              end; //vertex                  with ADODataset2 do
                begin
                  Append;
                  FieldValues['sub_mod']:=submodelname;
                  FieldValues['layer']:=LayerName(line_buffer.layer);
                  FieldValues['rev']:=revision;
                  FieldValues['grp_owner']:=textdata;
                  FieldValues['obj_type']:='D';
                  FieldValues['xmin']:=DimtoSingle(line_bufferextents.ext_x1);
                  FieldValues['ymin']:=DimtoSingle(line_bufferextents.ext_y1);
                  FieldValues['zmin']:=DimtoSingle(line_bufferextents.ext_z1);
                  FieldValues['xmax']:=DimtoSingle(line_bufferextents.ext_x2);
                  FieldValues['ymax']:=DimtoSingle(line_bufferextents.ext_y2);
                  FieldValues['zmax']:=DimtoSingle(line_bufferextents.ext_z2);
                  Post;
                end;
              ADODataset2.Last;                  if extrude=false then
                begin
                  with ADODataset3 do
                    begin
                      Append;
                      FieldValues['AutoObjectNumber']:=ADODataset2.FieldValues['AutoObjectNumber'];
                      FieldValues['Entity_Handle']:=inttostr(uniqueId);
                      FieldValues['Orig_Prim_type']:='POLYLINE';
                      FieldValues['color']:=ColorValue(line_buffer.color);
                      FieldValues['mark']:='-';
                      FieldValues['mat_prop_Id']:='-';
                      FieldValues['geom_type']:='PLINE';
                      FieldValues['data']:=VertexString;
                      Post;
                    end;
                end;
                
                if BuildingHeight>0 then
                  begin
                    For vertex:= 0 To lvertex-1 do
                      begin
                        VertexString:='12';
                        VertexString:=VertexString chr(9) FormatDimString(xp[vertex]) chr(9) FormatDimString(yp[vertex]) chr(9) floattostr(0.0);
                        VertexString:=VertexString chr(9) FormatDimString(xp[vertex]) chr(9) FormatDimString(yp[vertex]) chr(9) floattostr(BuildingHeight);
                        VertexString:=VertexString chr(9) FormatDimString(xp[vertex 1]) chr(9) FormatDimString(yp[vertex 1]) chr(9) floattostr(BuildingHeight);
                        VertexString:=VertexString chr(9) FormatDimString(xp[vertex 1]) chr(9) FormatDimString(yp[vertex 1]) chr(9) floattostr(0.0);                            with ADODataset3 do
                          begin
                            Append;
                            FieldValues['AutoObjectNumber']:=ADODataset2.FieldValues['AutoObjectNumber'];
                            FieldValues['Entity_Handle']:=inttostr(vertex 1);
                            FieldValues['Orig_Prim_type']:='FACE';
                            FieldValues['color']:=BuildingColor;
                            FieldValues['mark']:='-';
                            FieldValues['mat_prop_Id']:='-';
                            FieldValues['geom_type']:='MFACES';
                            FieldValues['data']:=VertexString;
                            Post;
                          end;
                      end;
                   end; //BuildingHeight>0                    if (lvertex=4) and (extrude=true) then
                  begin
                    VertexString:='24';
                    For vertex:= 0 To 4 do
                      begin
                        VertexString:=VertexString chr(9) FormatDimString(xp[vertex]) chr(9) FormatDimString(yp[vertex]) chr(9) floattostr(BuildingHeight);
                        VertexString:=VertexString chr(9) FormatDimString(xp[vertex 1]) chr(9) FormatDimString(yp[vertex 1]) chr(9) floattostr(BuildingHeight);
                      end; //vertex
                    with ADODataset3 do
                      begin
                        Append;
                        FieldValues['AutoObjectNumber']:=ADODataset2.FieldValues['AutoObjectNumber'];
                        FieldValues['Entity_Handle']:=inttostr(0);
                        FieldValues['Orig_Prim_type']:='FACE';
                        FieldValues['color']:=BuildingColor;
                        FieldValues['mark']:='-';
                        FieldValues['mat_prop_Id']:='-';
                        FieldValues['geom_type']:='MFACES';
                        FieldValues['data']:=VertexString;
                        Post;
                      end;
                  end; //lvertex=3    {
                //calculate area
                CdiArea(@xp, @yp, lvertex, area);
              with ADODataset3 do
                begin
                  Append;
                  FieldValues['AutoObjectNumber']:=ADODataset2.FieldValues['AutoObjectNumber'];
                  FieldValues['Entity_Handle']:=inttostr(uniqueId);
                  FieldValues['Orig_Prim_type']:='ATTRIBUTE';
                  FieldValues['color']:=ColorValue(line_buffer.color);
                  FieldValues['mark']:='-';
                  FieldValues['mat_prop_Id']:='-';
                  FieldValues['geom_type']:='AREA';
                  FieldValues['data']:=FormatAreaString(area);
                  Post;
                end;
}
                i_ret:=CdiEditDraw(object1.sid, 2);
          end;            CDI_3DLINESET:
          begin
            i_ret:=CdiObjInfo(object1.sid, @line3d_buffer);
            i_ret:=CdiGetUniqueId(object1.sid, uniqueId);
            lname:=LayerName(line3d_buffer.layer);
            CalculateMax3DExtents(line3d_buffer.extents, WorldCube);
            lvertex:=line3d_buffer.number_of_elements;
            VertexString:=inttostr(lvertex*3*2);
            For vertex:= 1 To lvertex do
              begin
                i_ret:= CdiObjInfoxyz(pnt1, op, vertex-1, line3d_buffer);
                i_ret:= CdiObjInfoxyz(pnt2, op, vertex, line3d_buffer);
                VertexString:=VertexString chr(9) FormatDimString(pnt1.x) chr(9) FormatDimString(pnt1.y) chr(9) FormatDimString(pnt1.z);
                VertexString:=VertexString chr(9) FormatDimString(pnt2.x) chr(9) FormatDimString(pnt2.y) chr(9) FormatDimString(pnt2.z);
              end; //vertex                  with ADODataset2 do
                begin
                  Append;
                  FieldValues['sub_mod']:=submodelname;
                  FieldValues['layer']:=LayerName(line3d_buffer.layer);
                  FieldValues['rev']:=revision;
                  FieldValues['grp_owner']:=inttostr(uniqueId);
                  FieldValues['obj_type']:='D';
                  FieldValues['xmin']:=DimtoSingle(line3d_buffer.extents.ext_x1);
                  FieldValues['ymin']:=DimtoSingle(line3d_buffer.extents.ext_y1);
                  FieldValues['zmin']:=DimtoSingle(line3d_buffer.extents.ext_z1);
                  FieldValues['xmax']:=DimtoSingle(line3d_buffer.extents.ext_x2);
                  FieldValues['ymax']:=DimtoSingle(line3d_buffer.extents.ext_y2);
                  FieldValues['zmax']:=DimtoSingle(line3d_buffer.extents.ext_z2);
                  Post;
                end;
              ADODataset2.Last;
              with ADODataset3 do
                begin
                  Append;
                  FieldValues['AutoObjectNumber']:=ADODataset2.FieldValues['AutoObjectNumber'];
                  FieldValues['Entity_Handle']:=inttostr(uniqueId);
                  FieldValues['Orig_Prim_type']:='POLYLINE';
                  FieldValues['color']:=ColorValue(line3d_buffer.color);
                  FieldValues['mark']:='-';
                  FieldValues['mat_prop_Id']:='-';
                  FieldValues['geom_type']:='PLINE';
                  FieldValues['data']:=VertexString;
                  Post;
                end;              end;            CDI_3DFACE:
          begin
            i_ret:=CdiObjInfo(object1.sid, @face_buffer);
            i_ret:=CdiGetUniqueId(object1.sid, uniqueId);
            lname:=LayerName(face_buffer.layer);
            CalculateMax3DExtents(face_buffer.extents, WorldCube);
            lvertex:=face_buffer.vertex_count;
            if (lvertex>2) and (lvertex<5) then
              begin                    VertexString:='12';
                for vertex:= 1 To lvertex do
                  begin
                    i_ret := CdiGetFacexyz(object1.sid, vertex-1, pnt1, op);
                    VertexString:=VertexString chr(9) FormatDimString(pnt1.x) chr(9) FormatDimString(pnt1.y) chr(9) FormatDimString(pnt1.z);
                  end; //vertex                    if lvertex<4 then
                  begin
                    VertexString:=VertexString chr(9) FormatDimString(pnt1.x) chr(9) FormatDimString(pnt1.y) chr(9) FormatDimString(pnt1.z);
                  end;
                //;
                with ADODataset2 do
                  begin
                    Append;
                    FieldValues['sub_mod']:=submodelname;
                    FieldValues['layer']:=LayerName(face_buffer.layer);
                    FieldValues['rev']:=revision;
                    FieldValues['grp_owner']:=inttostr(uniqueId);
                    FieldValues['obj_type']:='D';
                    FieldValues['xmin']:=DimtoSingle(face_buffer.extents.ext_x1);
                    FieldValues['ymin']:=DimtoSingle(face_buffer.extents.ext_y1);
                    FieldValues['zmin']:=DimtoSingle(face_buffer.extents.ext_z1);
                    FieldValues['xmax']:=DimtoSingle(face_buffer.extents.ext_x2);
                    FieldValues['ymax']:=DimtoSingle(face_buffer.extents.ext_y2);
                    FieldValues['zmax']:=DimtoSingle(face_buffer.extents.ext_z2);
                    Post;
                  end;
                ADODataset2.Last;
                with ADODataset3 do
                  begin
                    Append;
                    FieldValues['AutoObjectNumber']:=ADODataset2.FieldValues['AutoObjectNumber'];
                    FieldValues['Entity_Handle']:=inttostr(uniqueId);
                    FieldValues['Orig_Prim_type']:='FACE';
                    FieldValues['color']:=ColorValue(face_buffer.color);
                    FieldValues['mark']:='-';
                    FieldValues['mat_prop_Id']:='-';
                    FieldValues['geom_type']:='MFACES';
                    FieldValues['data']:=VertexString;
                    Post;
                  end;
            end; //(lvertex>2) and (lvertex<5)              end;            CDI_3DGROUP:
          begin
            i_ret:=CdiObjInfo(object1.sid, @symbol3d_buffer);
            i_ret:=CdiGetUniqueId(object1.sid, uniqueId);
            CalculateMax3DExtents(symbol3d_buffer.extents, WorldCube);
            lname:=LayerName(symbol3d_buffer.layer);
            VertexString:='7' chr(9) 
            BlockName chr(9) 
            floattostr(symbol3d_buffer.scale_x) chr(9) 
            floattostr(symbol3d_buffer.scale_y) chr(9) 
            floattostr(symbol3d_buffer.scale_z) chr(9) 
            floattostr(symbol3d_buffer.rotation_x) chr(9) 
            floattostr(symbol3d_buffer.rotation_y) chr(9) 
            floattostr(symbol3d_buffer.rotation_z);                with ADODataset2 do
              begin
                Append;
                FieldValues['sub_mod']:=submodelname;
                FieldValues['layer']:=LayerName(symbol3d_buffer.layer);
                FieldValues['rev']:=revision;
                FieldValues['grp_owner']:='GROUP-' inttostr(uniqueId);
                FieldValues['obj_type']:='D';
                FieldValues['xmin']:=DimtoSingle(symbol3d_buffer.extents.ext_x1);
                FieldValues['ymin']:=DimtoSingle(symbol3d_buffer.extents.ext_y1);
                FieldValues['zmin']:=DimtoSingle(symbol3d_buffer.extents.ext_z1);
                FieldValues['xmax']:=DimtoSingle(symbol3d_buffer.extents.ext_x2);
                FieldValues['ymax']:=DimtoSingle(symbol3d_buffer.extents.ext_y2);
                FieldValues['zmax']:=DimtoSingle(symbol3d_buffer.extents.ext_z2);
                Post;
              end;
            SaveMemberData(symbol3d_buffer.position, symbol3d_buffer.master_sgid, ADODataset2.FieldValues['AutoObjectNumber'], ADODataset3);              end;            CDI_3DSYMBOL:
          begin
            i_ret:=CdiObjInfo(object1.sid, @symbol3d_buffer);
            i_ret:=CdiGetUniqueId(object1.sid, uniqueId);
            CalculateMax3DExtents(symbol3d_buffer.extents, WorldCube);
            lname:=LayerName(symbol3d_buffer.layer);
            BlockName:=Copy(symbol3d_buffer.symbol_name,1, pos('.',symbol3d_buffer.symbol_name)) inttostr(uniqueid);
            VertexString:='7' chr(9) 
            BlockName chr(9) 
            floattostr(symbol3d_buffer.scale_x) chr(9) 
            floattostr(symbol3d_buffer.scale_y) chr(9) 
            floattostr(symbol3d_buffer.scale_z) chr(9) 
            floattostr(symbol3d_buffer.rotation_x) chr(9) 
            floattostr(symbol3d_buffer.rotation_y) chr(9) 
            floattostr(symbol3d_buffer.rotation_z);                with ADODataset2 do
              begin
                Append;
                FieldValues['sub_mod']:=submodelname;
                FieldValues['layer']:=LayerName(symbol3d_buffer.layer);
                FieldValues['rev']:=revision;
                FieldValues['grp_owner']:=BlockName inttostr(uniqueId);
                FieldValues['obj_type']:='D';
                FieldValues['xmin']:=DimtoSingle(symbol3d_buffer.extents.ext_x1);
                FieldValues['ymin']:=DimtoSingle(symbol3d_buffer.extents.ext_y1);
                FieldValues['zmin']:=DimtoSingle(symbol3d_buffer.extents.ext_z1);
                FieldValues['xmax']:=DimtoSingle(symbol3d_buffer.extents.ext_x2);
                FieldValues['ymax']:=DimtoSingle(symbol3d_buffer.extents.ext_y2);
                FieldValues['zmax']:=DimtoSingle(symbol3d_buffer.extents.ext_z2);
                Post;
              end;
            SaveMemberData(symbol3d_buffer.position, symbol3d_buffer.master_sgid, ADODataset2.FieldValues['AutoObjectNumber'], ADODataset3);
          end;            else          end; // case        end; //numb      ADODataSet1:=TADODataset.create(nil);
  with ADODataSet1 do begin
  ADODataSet1.CommandText:='SELECT * FROM [pSubModels]';
    ConnectionString:=ConnString;
    Open;
  end;      with ADODataset1 do
    begin
      Append;
      ADODataset1.FieldValues['sub_mod']:=submodelname;
      ADODataset1.FieldValues['descr']:=description;
      ADODataset1.FieldValues['status']:='test';
      ADODataset1.FieldValues['rev']:=revision;
      ADODataset1.FieldValues['xmin']:=DimtoSingle(WorldCube.ext_x1);
      ADODataset1.FieldValues['ymin']:=DimtoSingle(WorldCube.ext_y1);
      ADODataset1.FieldValues['zmin']:=DimtoSingle(WorldCube.ext_z1);
      ADODataset1.FieldValues['xmax']:=DimtoSingle(WorldCube.ext_x2);
      ADODataset1.FieldValues['ymax']:=DimtoSingle(WorldCube.ext_y2);
      ADODataset1.FieldValues['zmax']:=DimtoSingle(WorldCube.ext_z2);
      ADODataset1.FieldValues['updated']:=date;
      ADODataset1.FieldValues['owner']:='cadvance';
      Post;
    end;      SaveDialog1.Free;
//  ADODataSet4.Close;
  ADODataSet3.Close;
  ADODataSet2.Close;
  ADODataSet1.Close;
  ADODataSet1.Free;    end;    procedure SaveSubmodelLayers(const submodel:string; const revision:string ; const ConnString:string);
var
  LayerNumber:smallint;
  lname:string;
  ADODataSet1:TADODataset;    begin      ADODataSet1:=TADODataset.create(nil);
  with ADODataSet1 do begin
    ADODataSet1.CommandText:='SELECT * FROM [pLayers] WHERE [sub_mod]='''   submodel  '''';
    ConnectionString:=ConnString;
    Open;        for LayerNumber:=1 to 255 do
      begin            if (LayerVisible(LayerNumber)=CDI_YES) and (LayerHasData(LayerNumber)=CDI_TRUE) then
          begin
            lname:=LayerName(LayerNumber);
            with ADODataset1 do
              begin
                Append;
                ADODataset1.FieldValues['sub_mod']:=submodel;
                ADODataset1.FieldValues['rev']:=revision;
                ADODataset1.FieldValues['layer']:=lname;
                ADODataset1.FieldValues['description']:=lname ' (number: ' inttostr(LayerNumber) ')';
                ADODataset1.FieldValues['locked']:='UNLOCKED';
                ADODataset1.FieldValues['color']:=rgb(127,127,127);
                ADODataset1.FieldValues['alpha']:=1.0;
                ADODataset1.FieldValues['visibility']:='ON';
                Post;
              end;
            end; //(LayerVisible(LayerNumber)=CDI_YES) and (LayerHasData(LayerNumber)=CDI_TRUE)            end; //LayerNumber        end; //ADODataset      ADODataSet1.free;    end;    end.    --------------------------------------------------------------------------------    unit LayerUtilities;    interface    uses
  SysUtils,
  Cdiprocs,
  Cdiprocs3D,
  Cditypes,
  Cdiconst;      Procedure SelectLast;
  Procedure ViewLayersOn;
  Procedure ViewLayersOff;
  Procedure ViewZoomWindow;
  Procedure ViewZoomIn;
  Procedure ViewZoomOut;
  Procedure ViewLayersActive;
  Procedure ViewLayersAll;
  Procedure ZoomWorldExtents;
  Procedure ZoomCenterIn;
  Procedure ZoomCenterOut;
  Procedure ViewLast;
  Procedure ViewFit;
  Procedure PickLayerActive;
  Procedure PickLayerOff;
  Procedure PickLayerUnselect;
  Procedure layer_unselect(number:smallint);
  Procedure layer_off(number:smallint);
  Procedure layer_on(number:smallint);
  Procedure ViewObjectExtents;
  Procedure ViewOnlyLayersUsed;
  Procedure ViewLayersReverse;
  Procedure ViewVertex;      Procedure SetActiveLayerUp;
  Procedure SetActiveLayerDown;      function LayerVisible(const LayerNumber:smallint):smallint;
  function LayerColor(const LayerNumber:smallint):smallint;
  function LayerHasData(const LayerNumber:smallint):smallint;
  function LayerName(const LayerNumber:smallint):string;    implementation    Procedure SelectLast;
var
  i_ret:smallint;
  OslObj:CDI_OSL_OBJECT;    begin      OslObj.sid:=CdiGetLastId;
  i_ret:=CdiOslAdd(0, OslObj, CDI_TRUE);
  if i_ret=CDI_ERROR then
    begin
      CdiPutInfoMsg('','An error has occured adding to the selection set');
    end;    //  i_ret:=CdiObjDraw(0, CDI_HIGHLIGHT);
//  i_ret:=CdiEditDraw(OslObj.sid, CDI_HIGHLIGHT);    end;    Procedure PickLayerActive;
var
  i_ret:smallint;
  object1:CDI_OSL_OBJECT;
  pnt0:CDI_DDD_POINT;
  l_osl:CDI_SEGID;
  obj_type:smallint;
  layer:smallint;
  cvi_callback:PChar;    begin      l_osl:=CdiCreateLocalOsl(CDI_OBJECT_COLOR, @cvi_callback, CDI_REDRAW_OSL);      case CdiGetProgMode of
  CDI_2D_MODE:
    begin
      //snapmode=CdiGetSnapMode()
      i_ret:=CdiSetSnapMode(CDI_NOSNAP);
      i_ret:=CdiSelectbyPoint(l_osl,'Select object on layer to make active', CDI_OBJECT_SELECTION, CDI_FALSE, CDI_TRUE, pnt0, CDI_SEL2D_ALL);
      if i_ret=CDI_ABORT then
        begin
          i_ret:=CdiFreeLocalOsl(l_osl);
          exit;
        end;
      i_ret:=CdiOslItem(l_osl, 0, object1);
      i_ret:=CdiObjType(object1.sid, obj_type, layer);
      //i_ret=CdiSetSnapMode(snapmode)
    end;
  CDI_3D_MODE:
    begin
      //snapmode=CdiGet3DSnapMode()
      i_ret:=CdiSet3DSnapMode(CDI_NOSNAP);
      i_ret:=CdiSelect3DByPoint(l_osl, 'Select object on layer to make active', CDI_OBJECT_SELECTION, CDI_FALSE, CDI_TRUE, pnt0, CDI_SEL3D_ALL);
      if i_ret=CDI_ABORT then
        begin
          i_ret:=CdiFreeLocalOsl(l_osl);
          exit;
        end;          i_ret:=CdiOslItem(l_osl, 0, object1);
      i_ret:=CdiObjType(object1.sid, obj_type, layer);
      //i_ret=CdiSet3DSnapMode(snapmode);
    end;      end;      i_ret:=CdiSetActLayer(layer);
  i_ret:=CdiFreeLocalOsl(l_osl);
  CdiStatusLineUpdate;    end;    Procedure ViewLayersOn;
var
  i_ret:smallint;
  term:smallint;
  menu_hit:smallint;    begin      if CdiGetProgMode=CDI_2D_MODE then
    begin
      i_ret:=CdiNestedMenuEntry(IDM_VIEW_LAYERS_ON, term, menu_hit)
    end
  else
    begin
      i_ret:=C
        
系統時間:2024-07-02 16:26:22
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!