Client Feature 简介-1
来源:互联网 发布:淘宝助理导入csv卡住了 编辑:程序博客网 时间:2024/06/09 21:00
似乎还没有一篇介绍Client Feature的文章,包括我们全球博客。我来写两句。简单讲,Client Feature不是Inventor本身的功能。只有开发者能进行操作。通常两个方面的情况:
1. 自行组织Inventor的特征。
2. 附着Client Graphics。也是通过它,让Client Graphics保存到文档中。
例如,以下代码将某零件文档中的特征1和特征2添加到一个Client Feature之中。
Sub AddCF() Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition Set oDef = oDoc.ComponentDefinition 'get first feature Dim oPartFea1 As PartFeature Set oPartFea1 = oDef.Features(1) 'get second feature Dim oPartFea2 As PartFeature Set oPartFea2 = oDef.Features(2) 'create client feature definition Dim oClientFeatureDef As ClientFeatureDefinition Set oClientFeatureDef = oDef.Features.ClientFeatures.CreateDefinition("ClientFeatureTest") oClientFeatureDef.ClientFeatureElements.Add oPartFea1 oClientFeatureDef.ClientFeatureElements.Add oPartFea2 'create client feature Dim oClientFeature As ClientFeature Set oClientFeature = oDef.Features.ClientFeatures.Add(oClientFeatureDef, "ClientIDString") ThisApplication.ActiveView.UpdateEnd Sub
因此基本步骤是:首先利用ClientFeatures集合里的CreateDefinition创建一个定义,定义里添加对应的特征。最后使用ClientFeatures.Add这个定义,从而形成一个ClientFeature。
添加后:
可能以前你见到一些文档里有那样图标的节点,现在就明白是什么东东了。
大部分情况是利用Client Feature管理Client Graphics,每个例如以下代码在Client Feature里添加了一些自定义图线和形体。
Private Sub createCF_withCG() Dim oDoc As Document = m_invApp.ActiveDocument If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then 'assume you have got Inventor application Dim partDoc As PartDocument partDoc = m_invApp.ActiveDocument 'create client feature Dim cfDef As ClientFeatureDefinition cfDef = partDoc.ComponentDefinition.Features.ClientFeatures.CreateDefinition("My Test") Dim invCF As ClientFeature invCF = partDoc.ComponentDefinition.Features.ClientFeatures.Add(cfDef, "junk") Dim invCFD As ClientFeatureDefinition invCFD = invCF.Definition ' Get an arbitrary point on an edge of the feature, if the client feature has any elements. Dim oOrigin As Point ' There isn't any geometry so just place the graphics at the model origin. oOrigin = m_invApp.TransientGeometry.CreatePoint Dim oGraphicsData As GraphicsDataSets Try oGraphicsData = partDoc.GraphicsDataSetsCollection("TestCG_StoreData") Catch ex As Exception oGraphicsData = partDoc.GraphicsDataSetsCollection._Add2("TestCG_StoreData") End Try ' Create some client graphics. Dim oClientGraphics As Inventor.ClientGraphics Try oClientGraphics = invCFD.ClientGraphicsCollection("ClientFeatureTest") Catch ex As Exception oClientGraphics = invCFD.ClientGraphicsCollection.Add("ClientFeatureTest") End Try 'add some line strips Dim oCoordSet As GraphicsCoordinateSet oCoordSet = oGraphicsData.CreateCoordinateSet(oGraphicsData.Count + 1) Dim oGraphicsNode As GraphicsNode oGraphicsNode = oClientGraphics.AddNode(oClientGraphics.Count + 1) Dim oPointCoords(11) As Double 'create 4 points oPointCoords(0) = 0 : oPointCoords(1) = 0 : oPointCoords(2) = 0 oPointCoords(3) = 1 : oPointCoords(4) = 1 : oPointCoords(5) = 0 oPointCoords(6) = 2 : oPointCoords(7) = 0 : oPointCoords(8) = 0 oPointCoords(9) = 3 : oPointCoords(10) = 1 : oPointCoords(11) = 0 Call oCoordSet.PutCoordinates(oPointCoords) Dim oGraphic As LineGraphics oGraphic = oGraphicsNode.AddLineGraphics oGraphic.CoordinateSet = oCoordSet oGraphic.LineWeight = 5 'add a curve Dim oTG As TransientGeometry oTG = m_invApp.TransientGeometry 'create a circle Dim oCircle As Inventor.Circle oCircle = oTG.CreateCircle(oTG.CreatePoint(0, 0, 0), oTG.CreateUnitVector(0, 0, 1), 1.0#) 'add graphics with this circle Dim oGraphic1 As CurveGraphics oGraphic1 = oGraphicsNode.AddCurveGraphics(oCircle) oGraphic1.LineWeight = 10 'add a text Dim oTextGraphics As TextGraphics oTextGraphics = oGraphicsNode.AddTextGraphics 'Set the properties of the text oTextGraphics.Text = "Client Graphics Text" oTextGraphics.Anchor = oTG.CreatePoint(0, -0.5, 0) oTextGraphics.Bold = True oTextGraphics.Font = "Arial" oTextGraphics.FontSize = 40 oTextGraphics.HorizontalAlignment = HorizontalTextAlignmentEnum.kAlignTextLeft oTextGraphics.Italic = True Call oTextGraphics.PutTextColor(0, 255, 0) oTextGraphics.VerticalAlignment = VerticalTextAlignmentEnum.kAlignTextMiddle 'add some surface bodies Dim oTransientBRep As TransientBRep oTransientBRep = m_invApp.TransientBRep ' Create a point representing the center of the bottom of the cone Dim oBottom As Point oBottom = m_invApp.TransientGeometry.CreatePoint(0, 0, 0) ' Create a point representing the tip of the cone Dim oTop As Point oTop = m_invApp.TransientGeometry.CreatePoint(0, 1, 0) ' Create a transient cone body Dim oBody As SurfaceBody oBody = oTransientBRep.CreateSolidCylinderCone(oBottom, oTop, 0.2, 0.2, 0) ' Reset the top point indicating the center of the top of the cylinder oTop = m_invApp.TransientGeometry.CreatePoint(0, -2, 0) ' Create a transient cylinder body Dim oCylBody As SurfaceBody oCylBody = oTransientBRep.CreateSolidCylinderCone(oBottom, oTop, 0.2, 0.2, 0.2) ' Union the cone and cylinder bodies Call oTransientBRep.DoBoolean(oBody, oCylBody, BooleanTypeEnum.kBooleanTypeUnion) ' Create client graphics based on the transient body Dim oSurfaceGraphics As SurfaceGraphics oSurfaceGraphics = oGraphicsNode.AddSurfaceGraphics(oBody) <pre name="code" class="vb"> m_invApp.ActiveView.Update()<span style="font-family: Arial, Helvetica, sans-serif;"> </span>Else MsgBox("This sample creates a client feature with client graphics. Please open a part document!") End If End Sub
结果如图:
Autodesk 论坛帖:
如何设置Client Feature中 Client Graphics的材质?
http://forums.autodesk.com/t5/inventor-customization/applying-asset-to-client-feature-client-graphics-failure/m-p/4831971/highlight/true#M48659
0 0
- Client Feature 简介-1
- 修改Client Feature的图标
- Rich Client技术简介
- Rich Client技术简介
- Rich Client技术简介
- Rich Client技术简介
- Rich Client技术简介
- Instant Client简介
- Chrome Native Client 简介
- Zookeeper Client简介
- Zookeeper Client简介
- Zookeeper Client简介
- Chrome Native Client 简介
- Feature Set Mismatch Error on Ceph Kernel Client
- 4-1 Multiple Feature
- client (1)
- Sharepoint2007自定义Feature(1)--自定义Feature的基本流程
- CSS3特性查询(Feature Query: @supports)功能简介
- HTTP Error 500.24 / HTTP Error 404.2
- 按钮下自带划线 && 计算Label.text长度
- 4.Median of Two Sorted Arrays Leetcode Python
- JavaScript权威指南_48_第7章_数组_7.0-概述
- cocos studio 各模块使用方法
- Client Feature 简介-1
- 关于新版本struts2.3.16出现乱码问题
- C语言gettimeofday()函数:获取当前时间
- Hadoop学习总结之七:HDFS 操作
- 数据倾斜
- 多线程并发访问可能出现的崩溃问题
- Mac下Lua Sublime Text2 开发环境搭建
- LeetCode Unique Paths II
- 【小莨】如何打开扩展名为.DB 文件 ,sqlite3 的使用