我也碰到同样的问题啊 在数据库中读取了点的坐标,在模型空间里批量划线结果只显示一条画线 为什么 DataSet ds = new DataSet(); DataTable dt = new DataTable(); db con = new db(); con.OpenCon(); ds = con.RunSqlString(sqlstr, "点坐标"); con.CloseCon(); dt = ds.Tables["点坐标"]; double[] startPoint = new double[3]; //声明直线起点坐标 double[] endPoint = new double[3];//声明直线终点坐标 //对象集初始化 pipe_document = app_obj.ActiveDocument; //mospace = pipe_document.ModelSpace; pipe_layers = pipe_document.Layers; //添加点图层 point_layer = pipe_layers.Add("pointlayer"); //添加线图层 line_layer = pipe_layers.Add("linelayer"); // 设置线图层颜色 layercolor = (AcadAcCmColor)app_obj.GetInterfaceObject("AutoCAD.AcCmColor.17"); layercolor.SetRGB(122, 199, 25); line_layer.TrueColor = layercolor; //设置线图层的线的类型 line_layer.Linetype = "BORDER"; for (int j = 0; j < (dt.Rows.Count); j++) { for (int i = 0; i <= 2; i++) { startPoint = Convert.ToDouble(dt.Rows[j]);
} for (int i = 0; i <= 2; i++) { endPoint = Convert.ToDouble(dt.Rows[j][i + 3]); }
//在AutoCAD中画直线 ModelSpace.AddLine(startpoints, endpoints); } pipe_document.SetVariable("PDMODE", 96); pipe_document.SetVariable("PDSIZE", -5); app_obj.Visible = true; app_obj.ZoomAll(); app_obj.Application.Update();//更新显示 |