宏命令

录制一个宏命令来提取等高线,录制完成后转换出C#语言发现用不了,还有其他方法能解决吗?

  • 为提高论坛交流效率,请一次性将问题描述清楚并提供最充足的辅助材料。比如:提供您录制的宏,改写后的C# 代码以及录制用的DGN文件等。



  • Sub BmrzlinagDTM()
    Dim startPoint As Point3d
    Dim point As Point3d, point2 As Point3d
    Dim lngTemp As Long
    Dim oMessage As CadInputMessage

    ' 传送一个键入命令串
    CadInputQueue.SendKeyin "TERRAINMODEL DELTA "

    CadInputQueue.SendKeyin "CIVILCMD SETVALUE FeatureDefinition=<FeatureDefinition>Bentley.CifNET.GeometryModel.ContentManagement.TerrainObjectSettings, Bentley.CifNET.GeometryModel.4.0, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4bf6c96a266e58d4|" + Chr$(26080) + "特" + Chr$(24449) + Chr$(23450) + "义|False</FeatureDefinition> "

    CadInputQueue.SendKeyin "GEOMETRY ACTIVEFEATUREOVERRIDE False"

    ' 坐标以主单位计
    startPoint.X = 4958.92616334463
    startPoint.Y = 4843.63289494029
    startPoint.Z = 0#

    ' 给当前命令传送一个数据点
    point.X = startPoint.X
    point.Y = startPoint.Y
    point.Z = startPoint.Z
    CadInputQueue.SendDataPoint point, 1

    point.X = startPoint.X
    point.Y = startPoint.Y
    point.Z = startPoint.Z
    CadInputQueue.SendDataPoint point, 1

    point.X = startPoint.X
    point.Y = startPoint.Y
    point.Z = startPoint.Z
    CadInputQueue.SendDataPoint point, 1

    CadInputQueue.SendKeyin "CIVILCMD SETVALUE FeatureDefinition=<FeatureDefinition>Bentley.CifNET.GeometryModel.ContentManagement.TerrainObjectSettings, Bentley.CifNET.GeometryModel.4.0, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4bf6c96a266e58d4|" + Chr$(26080) + "特" + Chr$(24449) + Chr$(23450) + "义|False</FeatureDefinition> "

    point.X = startPoint.X
    point.Y = startPoint.Y
    point.Z = startPoint.Z
    CadInputQueue.SendDataPoint point, 1

    CommandState.StartDefaultCommand
    End Sub

  • Utilities.ComApp.CadInputQueue.SendKeyin("TERRAINMODEL DELTA ");
    Utilities.ComApp.CadInputQueue.SendKeyin("GEOMETRY ACTIVEFEATUREOVERRIDE False ");
    DPoint3d startPoint = new DPoint3d();
    startPoint.X = 4958.92616334463;
    startPoint.Y = 4843.63289494029;
    startPoint.Z = 0;

    Bentley.Interop.MicroStationDGN.Point3d lineptfirstM = new Bentley.Interop.MicroStationDGN.Point3d();
    lineptfirstM.X = startPoint.X;
    lineptfirstM.Y = startPoint.Y;
    lineptfirstM.Z = startPoint.Z;
    Bentley.Interop.MicroStationDGN.Point3d lineptsecondM = new Bentley.Interop.MicroStationDGN.Point3d();
    lineptsecondM.X = startPoint.X;
    lineptsecondM.Y = startPoint.Y;
    lineptsecondM.Z = startPoint.Z;
    Bentley.Interop.MicroStationDGN.Point3d lineptthirdM = new Bentley.Interop.MicroStationDGN.Point3d();
    lineptthirdM.X = startPoint.X;
    lineptthirdM.Y = startPoint.Y;
    lineptthirdM.Z = startPoint.Z;

    Utilities.ComApp.CadInputQueue.SendDataPoint(ref lineptfirstM, 1);
    Utilities.ComApp.CadInputQueue.SendDataPoint(ref lineptsecondM, 1);
    Utilities.ComApp.CadInputQueue.SendDataPoint(ref lineptthirdM, 1);

    //Utilities.ComApp.CadInputQueue.SendKeyin("CIVILCMD SETVALUE FeatureDefinition=<FeatureDefinition>Bentley.CifNET.GeometryModel.ContentManagement.TerrainObjectSettings, Bentley.CifNET.GeometryModel.4.0, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4bf6c96a266e58d4|" + Chr$(26080) + "特" + Chr$(24449) + Chr$(23450) + "义|False</FeatureDefinition> ");


    lineptthirdM.X = startPoint.X;
    lineptthirdM.Y = startPoint.Y;
    lineptthirdM.Z = startPoint.Z;
    Utilities.ComApp.CadInputQueue.SendDataPoint(ref lineptthirdM, 1);
    this.Close();

    注释掉的那行,写进宏命令会报格式错误