宏命令

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

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



  • 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();

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

  • 您不改成C# 代码请直接执行VBA代码能运行吗?



  • 建议使用ORD SDK的接口,

    获取当前DTM方法:见ORD SDK示例中的ManagedSDKExample中的TerrainReporter.cs

    获取等高线的方法:

    //获取等高线的方法
    private void CheckBrowseContourMethod(Bentley.TerrainModelNET.DTM dTM)
    {
    ContoursBrowsingDelegate hdl3P = new ContoursBrowsingDelegate(processContours);
    // BrowseContours methods
    ContoursBrowsingCriteria contoursCriteria = new ContoursBrowsingCriteria(1);
    contoursCriteria.SmoothingOption = TerrainModelNET.DTMContourSmoothingMethod.Vertex;//=1
    if (m_ExtractType == ExtractType.ConstantElevation)
    {
    contoursCriteria.UseOnlyContourValues = true;//获取特定高程等高线
    //double[] high = new double[1] { 14600000 };
    contoursCriteria.ContourValues = new double[1] { 1460.5 };//unit m
    }
    dTM.BrowseContours(contoursCriteria, hdl3P, null);

    }

    //绘制等高线的方法
    private bool processContours(DPoint3d[] tPoint, DPoint3d direction, System.Object oArg)
    {
    if (tPoint == null)
    {
    return false;
    }
    DgnModel dgnModel = Bentley.MstnPlatformNET.Session.Instance.GetActiveDgnModel();

    CurvePrimitive curvePri = CurvePrimitive.CreateLineString(tPoint);
    //CurveVector curveVec = CurveVector.Create(CurveVector.BoundaryType.Outer);
    Element lineEle = DraftingElementSchema.ToElement(dgnModel, curvePri, null);// UOR Unit

    if (m_ExtractType == ExtractType.RangeElevation)
    {//区间高程
    if (tPoint[0].Z % m_MajorInterval == 0)
    {
    //首曲线
    uint color = 3;
    ElementPropertiesSetter pSetter = new ElementPropertiesSetter();
    pSetter.SetColor(color);
    pSetter.Apply(lineEle);
    }
    else
    {
    //计曲线

    }
    }

    lineEle.AddToModel();
    return true;
    }

  • 这个接口是什么,之前听过,有视频教程或者资料吗?

Reply Children
No Data