我想生成一个10行的表格,表格中的列我想我想能够写,能够读,所以选择了属性块,但是我在插入属性块时,属性块不能在表格的行的中央!我看不出程序有什么问题,请高手帮帮忙!下面是程序代码! //在块中插入属性 procedure addattr(ptinsert:variant;b2: AcadBlock;attriname:string;attrtext:string;p:real;height:real; heightrec:real); var temp:variant; begin temp:=varArrayCreate([0,2],varDouble); temp[0]:=0; temp[1]:=0; temp[2]:=0; temp[0]:=ptinsert[0]+p;temp[1]:=ptinsert[1]+heightrec/2; temp[2]:=ptinsert[2]; b2.AddAttribute(height,0,attriname,temp,attriname,attrtext); end; //插入10行带属性的数据 procedure TForm1.Button15Click(Sender: TObject); var a:integer; b:integer; c:integer; d:integer; e:integer; f:integer; g:integer; h:integer; i:integer; p1,p2,p3,p4:olevariant; //块里面的直线点 p5,p6,p7,p8:olevariant;//插入点 p9:olevariant; p10:olevariant; p11:olevariant; p12:olevariant; p13:olevariant; p14:olevariant; p15:olevariant; p16:olevariant; p17:olevariant; p18:olevariant; m:integer;//循环步长 series:string; name:string; kkscode:string; reserve:string; cablestart:string; cableend:string; cabletype:string; remarks:string; begin a:=10; b:=55; c:=25; d:=70; e:=70; f:=55; g:=22; h:=45; i:=9; p1:=vararraycreate([0,2],varDouble);//一定要先创建 p2:=vararraycreate([0,2],varDouble); p3:=vararraycreate([0,2],varDouble); p4:=vararraycreate([0,2],varDouble); p5:=vararraycreate([0,2],varDouble); p6:=vararraycreate([0,2],varDouble); p7:=vararraycreate([0,2],varDouble); p8:=vararraycreate([0,2],varDouble); p9:=vararraycreate([0,2],varDouble); p10:=vararraycreate([0,2],varDouble); p11:=vararraycreate([0,2],varDouble); p12:=vararraycreate([0,2],varDouble); p13:=vararraycreate([0,2],varDouble); p14:=vararraycreate([0,2],varDouble); p15:=vararraycreate([0,2],varDouble); p16:=vararraycreate([0,2],varDouble); p17:=vararraycreate([0,2],varDouble); p18:=vararraycreate([0,2],varDouble); //------------------------------------------------------ ml:=acad.ActiveDocument.ModelSpace; p1[0]:=0; p1[1]:=0; p1[2]:=0;//基准点,以后要能交互选择 for m:=0 to 10 do begin p10[0]:=p1[0]; p10[1]:=p1[1]-i; p10[2]:=0; //--------------------------------------------------- p2[0]:=p1[0]+a; p2[1]:=p1[1]; p2[2]:=0; p11[0]:=p2[0]; p11[1]:=p2[1]-i; p11[2]:=0; //-------------------------------------------------------- p3[0]:=p2[0]+b; p3[1]:=p2[1]; p3[2]:=0; p12[0]:=p3[0]; p12[1]:=p3[1]-i; p12[2]:=0; //------------------------------------------------------ p4[0]:=p3[0]+c; p4[1]:=p3[1]; p4[2]:=0; p13[0]:=p4[0]; p13[1]:=p4[1]-i; p13[2]:=0; //------------------------------------------------------------ p5[0]:=p4[0]+d; p5[1]:=p4[1]; p5[2]:=0; p14[0]:=p5[0]; p14[1]:=p5[1]-i; p14[2]:=0; //------------------------------------------------------- p6[0]:=p5[0]+e; p6[1]:=p5[1]; p6[2]:=0; p15[0]:=p6[0]; p15[1]:=p6[1]-i; p15[2]:=0; //------------------------------------------------------- p7[0]:=p6[0]+f; p7[1]:=p6[1]; p7[2]:=0; p16[0]:=p7[0]; p16[1]:=p7[1]-i; p16[2]:=0; //------------------------------------------------------- p8[0]:=p7[0]+g; p8[1]:=p7[1]; p8[2]:=0; p17[0]:=p8[0]; p17[1]:=p8[1]-i; p17[2]:=0; //------------------------------------------------------- p9[0]:=p8[0]+h; p9[1]:=p8[1]; p9[2]:=0; p18[0]:=p9[0]; p18[1]:=p9[1]-i; p18[2]:=0; //------------------------------------------------------- bl:=acad.ActiveDocument.Blocks.Add(p1,inttostr(m)); //----------------------------------------------------- bl.addline(vararrayref(p1), vararrayref(p2)); bl.addline(vararrayref(p2), vararrayref(p3)); bl.addline(vararrayref(p3), vararrayref(p4)); bl.addline(vararrayref(p4), vararrayref(p5)); bl.addline(vararrayref(p5), vararrayref(p6)); bl.addline(vararrayref(p6), vararrayref(p7)); bl.addline(vararrayref(p7), vararrayref(p8)); bl.addline(vararrayref(p8), vararrayref(p9)); //----------------------------------------------------- bl.addline(vararrayref(p10), vararrayref(p11)); bl.addline(vararrayref(p11), vararrayref(p12)); bl.addline(vararrayref(p12), vararrayref(p13)); bl.addline(vararrayref(p13), vararrayref(p14)); bl.addline(vararrayref(p14), vararrayref(p15)); bl.addline(vararrayref(p15), vararrayref(p16)); bl.addline(vararrayref(p16), vararrayref(p17)); bl.addline(vararrayref(p17), vararrayref(p18)); //------------------------------------------------- bl.addline(vararrayref(p1), vararrayref(p10)); bl.addline(vararrayref(p2), vararrayref(p11)); bl.addline(vararrayref(p3), vararrayref(p12)); bl.addline(vararrayref(p4), vararrayref(p13)); bl.addline(vararrayref(p5), vararrayref(p14)); bl.addline(vararrayref(p6), vararrayref(p15)); bl.addline(vararrayref(p7), vararrayref(p16)); bl.addline(vararrayref(p8), vararrayref(p17)); bl.addline(vararrayref(p9), vararrayref(p18)); //------------------------------------------------------ addattr(p10,bl,'series','series',1,3,9); addattr(p11,bl,'name','name',1,3,9); addattr(p12,bl,'kkscode','kkscode',1,3,9); addattr(p13,bl,'reservecore','reservecore',1,3,9); addattr(p14,bl,'cablestart','cablestart',1,3,9); addattr(p15,bl,'cablesend','cablesend',1,3,9); addattr(p16,bl,'cabletype','cabletype',1,3,9); addattr(p17,bl,'remarks','remarks',1,3,9); //-------------------------------------------------------- acad.ActiveDocument.ModelSpace.InsertBlock(p1,bl.name,1,1,1,0,0); p1[0]:=0; p1[1]:=0-m*i; p1[2]:=0;//基准点,以后要能交互选择 end; |