using Autodesk.AECC.Interop.Land;
using Autodesk.AECC.Interop.UiLand;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
using Autodesk.Civil.Settings;
[assembly: CommandClass(typeof(NameTemplate.NameTemplateTest))]
namespace NameTemplate
{
class NameTemplateTest
{
string m_sAeccAppProgId = "AeccXUiLand.AeccApplication.11.0";
protected Document doc;
protected Database db;
protected Editor ed;
protected CivilDocument civilDoc;
ObjectId alignmentId;
ObjectId samplineGroupId; private IAcadApplication m_oAcadApp = null;
private IAeccApplication m_oAeccApp = null;
private IAeccDocument m_oAeccDoc = null;
private IAeccDatabase m_oAeccDb = null; AeccAlignment comAlignment;
AeccSampleLineGroup comSLG; public NameTemplateTest()
{
doc = Application.DocumentManager.MdiActiveDocument;
ed = doc.Editor;
db = doc.Database;
civilDoc = CivilApplication.ActiveDocument; m_oAcadApp = (IAcadApplication)Application.AcadApplication;
if (m_oAcadApp != null)
{
m_oAeccApp = (IAeccApplication)m_oAcadApp.GetInterfaceObject(m_sAeccAppProgId);
m_oAeccDoc = (IAeccDocument)m_oAeccApp.ActiveDocument;
m_oAeccDb = (IAeccDatabase)m_oAeccApp.ActiveDocument.Database;
}
}
public void ComNameTemplateTest()
{
if (m_oAeccDoc == null) return;
string name = m_oAeccDoc.Settings.AlignmentSettings.NameTemplate.Value;
object alignmentStyle = m_oAeccDoc.AlignmentStyles[];
object alignmentLadelset = m_oAeccDoc.AlignmentLabelStyleSets[];
string slgName = m_oAeccDoc.Settings.SampleLineSettings.GroupNameTemplate.Value;
AeccGroupPlotStyle GroupPlotStyle = m_oAeccDoc.GroupPlotStyles[];
AeccSampleLineStyle SampleLineStyle = m_oAeccDoc.SampleLineStyles[];
AeccLabelStyle SampleLineLabelStyle = m_oAeccDoc.SampleLineLabelStyles[];
string slName = m_oAeccDoc.Settings.SampleLineSettings.NameTemplate.Value;
double[] sp = new double[] { , , };
double[] ep = new double[] { , , }; for (int i = ; i < ; i++)
{
comAlignment = m_oAeccDoc.AlignmentsSiteless.Add(
name, "", alignmentStyle, alignmentLadelset);
comAlignment.Entities.AddFixedLine1(sp,ep);
for (int j = ; j < ; j++)
{
comSLG = comAlignment.SampleLineGroups.Add(
slgName, "", GroupPlotStyle, SampleLineStyle, SampleLineLabelStyle); double[] stations = new double[] { , , , , }; foreach (double sta in stations)
{
comSLG.SampleLines.AddByStation(slName, sta, , );
}
}
} } public void CreateSurfaceTest()
{
string name = civilDoc.Settings.GetSettings<
SettingsCmdCreateSurface>().NameFormat.Surface.Value;
//Create 3 TinSurface
for (int i = ; i < ; i++)
{
TinSurface.Create(db, name);
}
}
public void CreateSampleLineGroupTest()
{
if (alignmentId == ObjectId.Null) return;
try
{ string name = civilDoc.Settings.GetSettings<
SettingsSampleLine>().NameFormat.SampleLineGroup.Value;
//Create 3 SampleLineGroup
for (int i = ; i < ; i++)
{
samplineGroupId = SampleLineGroup.Create(name, alignmentId);
} }
catch (System.Exception ex)
{
ed.WriteMessage("\n" + ex.Message);
}
}
public void CreateSampleLineTest()
{
if (samplineGroupId == ObjectId.Null) return;
try
{ string name = civilDoc.Settings.GetSettings<
SettingsSampleLine>().NameFormat.SampleLine.Value;
double[] stations = new double[] { , , , , }; foreach (double sta in stations)
{
SampleLine.Create(name, samplineGroupId, sta);
}
}
catch (System.Exception ex)
{
ed.WriteMessage("\n" + ex.Message);
}
} public void CreateAlignmentTest()
{
try
{
string name = civilDoc.Settings.GetSettings<
SettingsCmdCreateAlignmentLayout>()
.DefaultNameFormat.AlignmentNameTemplate.Value;
ObjectId layerId;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
LayerTable layertable = db.LayerTableId.GetObject(
OpenMode.ForRead) as LayerTable;
layerId = layertable[""];
tr.Commit();
}
ObjectId styleId = civilDoc.Styles.AlignmentStyles[];
ObjectId labelsetId = civilDoc.Styles.LabelSetStyles
.AlignmentLabelSetStyles[];
for (int i = ; i < ; i++)
{
alignmentId= Alignment.Create(
civilDoc, name, ObjectId.Null, layerId, styleId, labelsetId);
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Alignment al = alignmentId.GetObject(OpenMode.ForWrite) as Alignment;
al.Entities.AddFixedLine(new Point3d(, , ), new Point3d(, , ));
tr.Commit();
}
}
}
catch (System.Exception ex)
{
ed.WriteMessage("\n" + ex.Message);
}
} [CommandMethod("ComTest")]
public void ComTest()
{
NameTemplateTest ntt = new NameTemplateTest();
ntt.ComNameTemplateTest();
}
[CommandMethod("NetTest")]
public void NetTest()
{
NameTemplateTest ntt = new NameTemplateTest();
ntt.CreateSurfaceTest();
ntt.CreateAlignmentTest();
ntt.CreateSampleLineGroupTest();
ntt.CreateSampleLineTest(); }
}
} 使用NET API,曲面名称模板可以正常工作,采样线和路线名称模板不能正常工作。  使用COM API 路线的采样线名称模板正常工作,采样线编组不行。

Civil 3D 二次开发 名称模板不能正常工作的更多相关文章

  1. Civil 3D 二次开发 创建Civil 3D 对象—— 01 —— 创建几何空间点

    这一小节,我们创建派生于CivilCreateEntityDemo的类CivilCreateCogoPoint,来创建几何空间点. 1 创建类并添加字段及方法 首先在项目资源管理器中向本项目中添加类, ...

  2. 学习 Civil 3D二次开发从哪儿开始?

    1.1 从哪儿开始 对于多数的工程设计人员,不完全具备上节所述的各种条件.对于Civil 3D的应用可能比较熟悉:但对于计算机语言,只限于上学时所学的一点基础知识,步入工作岗位后与计算机语言基本无缘: ...

  3. Civil 3D 二次开发 创建Civil 3D 对象—— 00 ——

    本节中我们通过创建几何空间点.曲面和采样线了解Civil 3D对象的创建方法.因Civil 3D对象的创建方法相比AutoCAD对象创建要简单的多,比如创建一个几何空间点,最简单的情况采用一行代码(没 ...

  4. Civil 3D 二次开发 创建AutoCAD对象—— 00 ——

    不积跬步无以至千里,不积小流无以成江海.虽然创建一条直线.添加一个图层这样的小程序没有什么实际意义(内部命令很简单就可以完成),但对于初学二次开发的您来说,这可是一大步,这一步跨出去,您就跨进了二次开 ...

  5. Civil 3D 二次开发 创建AutoCAD对象—— 01 —— 创建直线

    在方法CreateLine内完成以下代码: 01 public void CreateLine() 02 { 03 PromptPointOptions ppo = new PromptPointOp ...

  6. Civil 3D 二次开发 事务

    事务,一般是指要做的或所做的事情.在计算机术语中是指访问并可能更新数据库中各种数据项的一个程序执行单元(unit). 对于初学者来说,从字面上难以理解什么是事务.下面我试着通过讲述事务的作用及特性来帮 ...

  7. Civil 3D 二次开发 翻转曲面高程分析颜色

    不解释,直接上代码及截图. [CommandMethod("RvsSEA")] public void ReverseSurfaceElevationAnalysis() { Ci ...

  8. Civil 3D 二次开发 新建CLR项目出现错误C2143

    新建CLR项目出现错误C2143 按照Objectarx Training创建.net混合项目,编译时出现一下错误: 原因不明: 解决方法: 在Stdafx.h文件中添加: #define WIN32 ...

  9. TFS二次开发系列:五、工作项查询

    本节将讲述如何查询工作项,用于二次开发中定义获取工作项列表. 使用WorkItemStore.Query方法进行查询工作项,其使用的语法和SQL语法类似: Select [标题] from worki ...

随机推荐

  1. FineUIMvc随笔(3)不能忘却的回发(__doPostBack)

    声明:FineUIMvc(基础版)是免费软件,本系列文章适用于基础版. 用户反馈 有网友在官方论坛抛出了这么一个问题,似乎对 FineUIMvc 中的浏览器端与服务器端的交互方式很有异议. 这里面的关 ...

  2. 封装HttpUrlConnection开箱即用

    因为经常用到 便写出来方边使用 直接复制本类即可 import java.io.*; import java.net.HttpURLConnection; import java.net.URL; i ...

  3. 微信小程序获取formId时提示"the formId is a mock one"

    微信小程序使用模板消息需要使用表单提交 formId,因此进行了简单的代码测试,在 wxml 文件中创建 form 对象,并在 form 标签中声明属性 report-submit="tru ...

  4. CSS Modules入门教程

    为什么引入CSS Modules 或者可以这么说,CSS Modules为我们解决了什么痛点.针对以往我写网页样式的经验,具体来说可以归纳为以下几点: 全局样式冲突 过程是这样的:你现在有两个模块,分 ...

  5. 蛙蛙推荐: TensorFlow Hello World 之平面拟合

    tensorflow 已经发布了 2.0 alpha 版本,所以是时候学一波 tf 了.官方教程有个平面拟合的类似Hello World的例子,但没什么解释,新手理解起来比较困难. 所以本文对这个案例 ...

  6. 七、xadmin 编辑界面实现二级联动

    很多时候,我们会遇到这种需求,通过一个select框中选择的值,去动态的加载另一个下拉框中的内容 对于前端的同学来讲,这个本应该是一个很简单的需求,获取第一个下拉框的值然后通过ajax去动态加载即可. ...

  7. rest_framework之视图及源码剖析

    最初形态(工作中可能会使用) 引子 Django的CBV我们应该都有所了解及使用,大体概括一下就是通过定义类并在类中定义get post put delete等对应于请求方法的方法,当请求来的时候会自 ...

  8. 替换iframe的内容

    一般就是点个按钮然后在不跳转页面的情况下显示另外一个页面的内容,显示的速度比较快,ifream还算是常用的吧 用的时候实现方式有以下几种, 1.替换src路径(觉得麻烦,没接触过,就不这样干了) 2. ...

  9. Shell脚本命令图片

    查看相关文档:shell脚本1  shell脚本2

  10. c# Mongodb两个字段不相等 MongoDB原生查询

    var document = new BsonDocument{ { "$where","this.StarTime!=this.EndTime"}, { }, ...