lst.Add(args<i>);
提示如下错误:
错误 CS0307 变量“pars”不能与类型参数一起使用
错误 CS0118 “i”是 变量,但此处被当做 类型 来使用
错误 CS0307 变量“ref object[]”不能与类型参数一起使用
错误 CS0118 “i”是 变量,但此处被当做 类型 来使用
请问是什么原因? 不错,C#在com方面的介绍比起VB太少了 雪山飞狐_lzh 发表于 2015-4-5 14:53
变体参数的反射
Utiility类中大量的函数使用了变体。。。
能否帮忙将这个单个CAD版本的应用程序修改为适合多个CAD版本的应用程序,如2010,2013等版本,本人愿意支付一定的费用,联系QQ:1067426844。程序码如下:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
namespace CAD二次开发
{
public partial class Form1 : Form
{
public static Autodesk.AutoCAD.Interop.AcadApplication AcadApp;
public static Autodesk.AutoCAD.Interop.AcadDocument AcadDoc;
public Form1()
{
InitializeComponent();
}
public static void 启动CAD()
{
try
{
AcadApp = (AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application");
AcadDoc = AcadApp.ActiveDocument;
}
catch
{
AcadApp = new AcadApplication();
AcadDoc = AcadApp.ActiveDocument;
}
AcadApp.Application.Visible = true;
Microsoft.VisualBasic.Interaction.AppActivate(AcadApp.Caption);
}
private void button1_Click(object sender, EventArgs e)
{
启动CAD();
double Ks =0;
double Ke = 2000;
double Dmax = 150;
double Dmin = -150;
string VerCAD = (AcadApp.Version.ToString()).Substring(0, 2);//获取AutoCAD版本号,从左边截取2位字符
AcadAcCmColor color1 = (AcadAcCmColor)AcadDoc.Application.GetInterfaceObject("AutoCAD.AcCmColor." + VerCAD);//新建一AcadAcCmColor对象,该对象用来给图形对象的颜色属性赋值
AcadLayer acLayer;
AcadText TextObj;
acLayer = AcadDoc.Layers.Add("中心线");
acLayer.color = AcColor.acYellow;
acLayer.Lineweight = ACAD_LWEIGHT.acLnWt025;
acLayer = AcadDoc.Layers.Add("文字标注");
acLayer.color = AcColor.acGreen;
acLayer = AcadDoc.Layers.Add("主网格");
color1.SetRGB(66, 112, 138);
acLayer.TrueColor = color1;
acLayer.Lineweight = ACAD_LWEIGHT.acLnWt015;
acLayer = AcadDoc.Layers.Add("副网格");
color1.SetRGB(95, 58, 69);
acLayer.TrueColor = color1;
acLayer.Lineweight = ACAD_LWEIGHT.acLnWt005;
double[] lineStartPoint = new Double;
double[] lineEndPoint = new Double;
double[] TextPoint = new Double;
//水平网格线
for (int i = Convert.ToInt32(Math.Ceiling(Dmin / 10)) * 10; i <= Math.Floor(Dmax / 10) * 10; i = i + 10)
{
lineStartPoint = Ks ; lineStartPoint = i;
lineEndPoint = Ke ; lineEndPoint = i;
if (i % 50 == 0)
{
if (i == 0)
{
AcadDoc.ModelSpace.AddLine(lineStartPoint, lineEndPoint).Layer = "中心线";
}
else
{
AcadDoc.ModelSpace.AddLine(lineStartPoint, lineEndPoint).Layer = "主网格";
}
}
else
{
AcadDoc.ModelSpace.AddLine(lineStartPoint, lineEndPoint).Layer = "副网格";
}
}
//竖向网格线
for (int i = Convert.ToInt32(Math.Ceiling(Ks / 10)) * 10; i <= Math.Floor(Ke / 10) * 10; i = i + 10)
{
lineStartPoint = i ; lineStartPoint = Math.Ceiling(Dmin / 10) * 10;
lineEndPoint = i ; lineEndPoint = Math.Floor(Dmax / 10) * 10;
if (i % 50 == 0)
{
AcadDoc.ModelSpace.AddLine(lineStartPoint, lineEndPoint).Layer = "主网格";
if (i % 100 == 0)
{
//标注里程
TextPoint = i ; TextPoint = Math.Ceiling(Dmin / 10) * 10 - 10;
string strText;
if (i % 1000 == 0)
{
strText = "K" + (i / 1000).ToString();
}
else
{
strText = ((i / 100) % 10).ToString();
}
TextObj = AcadDoc.ModelSpace.AddText(strText, TextPoint, 7.5);
TextObj.Alignment = AcAlignment.acAlignmentMiddleCenter;//文本对齐方式
TextObj.TextAlignmentPoint = TextPoint;
TextObj.Layer = "文字标注";
//标注拨量
if (i % 1000 == 0)
{
for (int j = Convert.ToInt32(Math.Ceiling(Dmin / 50)) * 50; j <= Math.Floor(Dmax / 50) * 50; j = j + 50)
{
TextPoint = i- 5; TextPoint = j;
TextObj = AcadDoc.ModelSpace.AddText(j.ToString(), TextPoint, 7.5);
TextObj.Alignment = AcAlignment.acAlignmentMiddleRight;//文本对齐方式
TextObj.TextAlignmentPoint = TextPoint; //文本对齐点
TextObj.Layer = "文字标注";
}
}
}
}
}
AcadDoc.ActiveLayer = AcadDoc.Layers.Add("0");//恢复0图层
AcadDoc.SendCommand("_z\ne\n");
AcadDoc.SendCommand("_regenall\n");//全部重生成模型
Microsoft.VisualBasic.Interaction.AppActivate(AcadApp.Caption);
}
}
}
mark 飞狐大侠,你好。从你的帖子中学到了很多,非常感谢。
有一个问题请教 一下:使用C# COM,怎么调用sendcommand命令,实现两条直线trim的功能?(在sendcommand命令中,可以使用handent,但是无法使用list()),或者不用调用sendcommand,有无其它命令。
非常期待能获得你的指点。
页:
1
[2]