求ObjectDBX 1.0
<p>下面这段程序应用于找尺寸线的块,需要ObjectDBX 1.0 Type Library和Axdb15.dll。请问哪里能得到ObjectDBX 1.0 Type Library</p><p></p><p><strong>Re: Dimension handles<br/></strong>Not suprising that a hack like that doesn't always<br/>work. This will always work, and doesn't rely on<br/>hacks based on lame assumptions.<br/><br/>Before this will work, you will need to register AxDb15.dll<br/>which is located in the same folder as acad.exe, and you<br/>must include a reference to the "ObjectDBX 1.0 Type Library"<br/>in your project.<br/><br/>Public Function GetDimBlock(Dimension As AcadDimension) As AcadBlock<br/>Dim dbxDoc As New AxDbDocument<br/>Dim Doc As AcadDocument<br/>Set Doc = Dimension.Document<br/>Dim IdPairs As Variant<br/>Dim IdPair As AcadIdPair<br/>Dim ObjArray(0 To 0) As AcadObject<br/>Set ObjArray(0) = Dimension<br/>Doc.CopyObjects ObjArray, dbxDoc.ModelSpace, IdPairs<br/>Dim i As Integer<br/>For i = LBound(IdPairs) To UBound(IdPairs)<br/>Set IdPair = IdPairs(i)<br/>Dim Obj As AcadObject<br/>Set Obj = Doc.ObjectIdToObject(IdPair.Key)<br/>If TypeOf Obj Is AcadBlock Then<br/>Dim ABlock As AcadBlock<br/>Set ABlock = Obj<br/>If Left(ABlock.Name, 2) = "*D" Then<br/>Set GetDimBlock = Obj<br/>Exit Function<br/>End If<br/>End If<br/>Next i<br/>End Function<br/><br/>Public Sub Test()<br/>Dim Dimension As AcadDimension<br/>Utility.GetEntity Dimension, Pt, vbCrLf & "Select dimension: "<br/>Dim DimBlock As AcadBlock<br/>Set Block = GetDimBlock(Dimension)<br/>Debug.Print "Dimension block name = " & Block.Name<br/>End Sub</p><p>网站链接<a href="http://discussion.autodesk.com/thread.jspa?messageID=382642">http://discussion.autodesk.com/thread.jspa?messageID=382642</a><br/></p> 官方网站上去找 本帖最后由 作者 于 2008-8-1 13:23:50 编辑 <br /><br /> <p>谢谢,郑先生的指点。</p><p>Dim dbxDoc As New AxDbDocument,此条语句已经通过。<br/><br/>但这条语句没通过。Doc.CopyObjects ObjArray, dbxDoc.ModelSpace, IdPairs<br/></p><p class="body">要复制多个对象,请使用 <object id="alink_CopyObjects_AXM_388919" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><param value="106" name="Width"/><param value="53" name="Height"/><param value="ALink" name="Command"/><param value="acadauto.chm" name="Item1"/><param value="CopyObjects_AXM" name="Item2"/></object>CopyObjects 方法,或者创建一个阵列数组,与 <object id="alink_Copy_AXM_388919" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><param value="106" name="Width"/><param value="53" name="Height"/><param value="ALink" name="Command"/><param value="acadauto.chm" name="Item1"/><param value="Copy_AXM" name="Item2"/></object>Copy 方法配合使用。(要复制选择集中的对象,请遍历选择集并将对象保存到数组中。)遍历数组,分别复制每个对象,然后将新创建的对象收集到第二个数组中。 </p><p class="body">要将多个对象复制到不同的图形,请使用 CopyObjects 方法并将 Owner 参数设置为该图形的模型空间。 </p><p>相关帖子:<strong>利用ObjectDBX技术导入其它图形中的图层设置和文字样式设置</strong></p><p><a href="http://bbs.mjtd.com/forum.php?mod=viewthread&tid=12482&extra=&page=1">http://bbs.mjtd.com/forum.php?mod=viewthread&tid=12482&extra=&page=1</a></p><p>Object:<a href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202004\help\acadauto.chm::/idh_database_object.htm">Database</a>, <a href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202004\help\acadauto.chm::/idh_document_object.htm">Document</a><br/>The object or objects this method applies to. </p><p>对象:数据库,文件:</p><p>对象或对象应用方法</p><p>Objects</p><p class="element-desc">Variant (array of objects); input-only<br/>The array of primary objects to be copied. All the objects must have the same owner, and the owner must belong to the database or document that is calling this method. </p><p class="element-desc">对象:变体变量(对象数组),只读型。初始化目标数组的拷贝,全部目标有相同的owner,owner必须属于同一数据库或文件的调用。</p><p class="element">Owner</p><p class="element-desc">Variant (a single object); input-only; optional<br/>The new owner for the copied objects. If no owner is specified, the objects will be created with the same owner as the objects in the Objects array. </p><p class="element">IDPairs</p><p class="element-desc">Variant (array of IDPair objects); input-output; optional<br/>Information on what happened during the copy and translation process.<br/>Input: an empty variant.<br/>Output: an array of IDPair objects.</p><p class="element-desc"><a href="http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=646">http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=646</a></p><p class="element-desc">在VBA中可以用CopyObjects方法将对象拷贝到块中。<br/>运用此方法可以进行块的重定义等。<br/>函数原型:RetVal = object.CopyObjects(Objects[, Owner][, IDPairs])<br/>Object:文档对象 <br/>Objects:要拷贝的对象集合<br/>Owner:拷贝生成的新对象的宿主对象,可以是块或者另一个文档。<br/>程序示例如下:<br/><br/>Sub Text()<br/><br/>' 创建块<br/><br/>Dim blockObj As AcadBlock<br/>Dim insertionPnt(0 To 2) As Double<br/>insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#<br/>Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "CircleBlock")<br/><br/>' 在模型空间添加圆<br/><br/>Dim circleObj As AcadCircle<br/>Dim center(0 To 2) As Double<br/>Dim radius As Double<br/>center(0) = 0: center(1) = 0: center(2) = 0<br/>radius = 1<br/>Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)<br/><br/>' 创建对象集合<br/><br/>Dim objCollection(0 To 0) As Object<br/>Set objCollection(0) = circleObj<br/><br/>' 拷贝对象到块中,并返回新拷贝的对象<br/><br/>Dim retObjects As Variant<br/>retObjects = ThisDrawing.CopyObjects(objCollection, blockObj)<br/><br/>' 插入块到模型空间<br/>Dim blockRefObj As AcadBlockReference<br/>insertionPnt(0) = 2#: insertionPnt(1) = 2#: insertionPnt(2) = 0<br/><br/>Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)<br/><br/>ZoomAll<br/><br/>End Sub</p> 你的dbxDoc并没有打开的图形,怎么会有ModelSpace
页:
[1]