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终极教程
一:前言 Spring 有XML配置和注解两种版本,我个人非常喜欢使用注解,相当热衷Spring boot! 对于Spring,核心就是IOC容器,这个容器说白了就是把你放在里面的对象(Bean)进行 ...
- 用HttpClient和用HttpURLConnection做爬虫发现爬取的代码少了的问题
最近在学习用java来做爬虫但是发现不管用那种方式都是爬取的代码比网页的源码少了很多在网上查了很多都说是inputStream的缓冲区太小而爬取的网页太大导致读取出来的网页代码不完整,但是后面发现并不 ...
- 线程锁(互斥锁Mutex)及递归锁
一.线程锁(互斥锁) 在一个程序内,主进程可以启动很多个线程,这些线程都可以访问主进程的内存空间,在Python中虽然有了GIL,同一时间只有一个线程在运行,可是这些线程的调度都归系统,操作系统有自身 ...
- Problem 2285 迷宫寻宝
http://acm.fzu.edu.cn/problem.php?pid=2285 Problem Description 洪尼玛今天准备去寻宝,在一个n*n (n行, n列)的迷宫中,存在着一个入 ...
- MYSQL行号
mysql 实现行号的方法——如何获取当前记录所在行号 - senly - 博客园http://www.cnblogs.com/xinlei/archive/2011/12/16/2290349.ht ...
- 启动Tomcat的时候8080被占用
异常来源:启动Tomcat服务器报错: Several ports (8080, 8009) required by Tomcat v7.0 Server at localhost are alrea ...
- Yii的操作提示框
效果如图 HTML + CSS<style> div.error{ background: #FFE0E0; border: 2px solid #FFA0A0; padding: 10p ...
- css3新属性box-orient
前言 box-orient属性经常与display:box属性结合使用 div { width:350px; height:100px; border:1px solid black; /* Fire ...
- 994.Contiguous Array 邻近数组
描述 Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and ...
- 【学亮IT手记】jQuery text()/html()回调函数实例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...
