Civil 3D 二次开发 名称模板不能正常工作
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 二次开发 名称模板不能正常工作的更多相关文章
- Civil 3D 二次开发 创建Civil 3D 对象—— 01 —— 创建几何空间点
这一小节,我们创建派生于CivilCreateEntityDemo的类CivilCreateCogoPoint,来创建几何空间点. 1 创建类并添加字段及方法 首先在项目资源管理器中向本项目中添加类, ...
- 学习 Civil 3D二次开发从哪儿开始?
1.1 从哪儿开始 对于多数的工程设计人员,不完全具备上节所述的各种条件.对于Civil 3D的应用可能比较熟悉:但对于计算机语言,只限于上学时所学的一点基础知识,步入工作岗位后与计算机语言基本无缘: ...
- Civil 3D 二次开发 创建Civil 3D 对象—— 00 ——
本节中我们通过创建几何空间点.曲面和采样线了解Civil 3D对象的创建方法.因Civil 3D对象的创建方法相比AutoCAD对象创建要简单的多,比如创建一个几何空间点,最简单的情况采用一行代码(没 ...
- Civil 3D 二次开发 创建AutoCAD对象—— 00 ——
不积跬步无以至千里,不积小流无以成江海.虽然创建一条直线.添加一个图层这样的小程序没有什么实际意义(内部命令很简单就可以完成),但对于初学二次开发的您来说,这可是一大步,这一步跨出去,您就跨进了二次开 ...
- Civil 3D 二次开发 创建AutoCAD对象—— 01 —— 创建直线
在方法CreateLine内完成以下代码: 01 public void CreateLine() 02 { 03 PromptPointOptions ppo = new PromptPointOp ...
- Civil 3D 二次开发 事务
事务,一般是指要做的或所做的事情.在计算机术语中是指访问并可能更新数据库中各种数据项的一个程序执行单元(unit). 对于初学者来说,从字面上难以理解什么是事务.下面我试着通过讲述事务的作用及特性来帮 ...
- Civil 3D 二次开发 翻转曲面高程分析颜色
不解释,直接上代码及截图. [CommandMethod("RvsSEA")] public void ReverseSurfaceElevationAnalysis() { Ci ...
- Civil 3D 二次开发 新建CLR项目出现错误C2143
新建CLR项目出现错误C2143 按照Objectarx Training创建.net混合项目,编译时出现一下错误: 原因不明: 解决方法: 在Stdafx.h文件中添加: #define WIN32 ...
- TFS二次开发系列:五、工作项查询
本节将讲述如何查询工作项,用于二次开发中定义获取工作项列表. 使用WorkItemStore.Query方法进行查询工作项,其使用的语法和SQL语法类似: Select [标题] from worki ...
随机推荐
- Spring Boot 之使用 Json 详解
Spring Boot 之使用 Json 详解 简介 Spring Boot 支持的 Json 库 Spring Web 中的序列化.反序列化 指定类的 Json 序列化.反序列化 @JsonTest ...
- 【转】AlphaGO Zero 原理
原文地址:https://www.hhyz.me/2018/08/08/2018-08-08-AlphaGO-Zero/> 1. 概述 简单来说,AlphaGo Zero 的训练可以分为三个 ...
- django url之path默认参数
url path指向视图创建和更新数据 实例: from django.urls import path from . import views urlpatterns = [ path('blog/ ...
- Python云端系统开发入门 pycharm代码
html <!DOCTYPE html><html><head> <meta charset="UTF-8"> <title& ...
- Iar8.1安装包破解
Iar8.1安装包链接链接:https://pan.baidu.com/s/1F6sxEcatk3_YPq47lvc8Mw 密码:mnlz 破解链接 https://www.cnblogs.com/ ...
- redis的应用场景 为什么用redis
一.不是万能的菲关系系数据库redis 在面试的时候,常被问比较下Redis与Memcache的优缺点,个人觉得这二者并不适合一起比较,redis:是非关系型数据库不仅可以做缓存还能干其它事情,Mem ...
- python 中的re模块,正则表达式
一.re模块 re模块中常用的方法. match: 默认从字符串开头开始匹配,re.match('fun', 'funny') 可以匹配出来 'fun' match(pattern, string, ...
- 修改eclipce操作权限
<dependencies> <dependency> <groupId>jdk.tools</groupId> <artifactId>j ...
- MapReduce过程<原创>
一.预处理阶段 二.Map阶段 一个Map任务被JobTracker(管家)分配到多个TaskTracker(弟弟)执行,如下图所示,弟弟的map()只负责拆分,虽然map()输出两个相同的键值对,但 ...
- php开发之常用验证方法
1.邮箱验证 function isEmail($email) { if (!$email) { return false; } return preg_match('/^[_\.0-9a-z-]+@ ...