wzw393831667 发表于 2009-5-9 15:10:00

[求助]怎么将cad中的直线偏移一定距离

<p>以下是源程序:程序的目的是在有各种图形的cad图中,把直线选出来,之后再将直线偏移一定的距离。 现在我可以选出直线,但是不知道该怎么偏移。请大家帮下忙~不盛感激。</p><p></p><p>Dim acadDoc As Object<br/>Dim acadApp As Object</p><p><br/>Private Sub CmdTj_Click()</p><p>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; MsgBox "There are " &amp; acadDoc.Layers.Count &amp; " layer(s) in the drawing."<br/>&nbsp;&nbsp;&nbsp; MsgBox "There are " &amp; acadDoc.ModelSpace.Count &amp; " object(s) in ModelSpace."</p><p>&nbsp;&nbsp;&nbsp; Dim objCount As Integer<br/>&nbsp;&nbsp;&nbsp; Dim I As Integer<br/>&nbsp;&nbsp;&nbsp; objCount = acadDoc.ModelSpace.Count<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim mspaceObj As AcadObject</p><p>&nbsp;&nbsp;&nbsp; For I = 0 To objCount - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp; Set mspaceObj = acadDoc.ModelSpace.Item(I)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If mspaceObj.ObjectName = "AcDbLine" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "The objects in ModelSpace include: " &amp; mspaceObj.ObjectName, vbInformation, "Count Example"<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; Next<br/>End Sub</p><p>Private Sub Form_Load()<br/>Set acadApp = GetObject(, "AutoCAD.Application")<br/>Set acadDoc = acadApp.ActiveDocument<br/>End Sub</p><p></p><p></p>

雪山飞狐_lzh 发表于 2009-5-9 15:22:00

<p class="1-liner">Moves an object along a vector.</p><p class="h1-access"><a href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202008\help\acadauto.chm::/move_see_also.htm">See Also</a> | <a href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202008\help\acadauto.chm::/ex_move.htm">Example</a></p><p class="Heading-2">Signature </p><p class="syntax">object.Move Point1, Point2 </p><p class="element">Object</p><p class="element-desc"><a href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202008\help\acadauto.chm::/all_drawing_objects.htm">All Drawing Objects</a>, <a href="mk:@MSITStore:C:\Program%20Files\AutoCAD%202008\help\acadauto.chm::/idh_attributeref_object.htm">AttributeReference</a><br/>The object or objects this method applies to. </p><p class="element">Point1</p><p class="element-desc">Variant (three-element array of doubles); input-only<br/>The 3D WCS coordinates specifying the first point of the move vector. </p><p class="element">Point2</p><p class="element-desc">Variant (three-element array of doubles); input-only<br/>The 3D WCS coordinates specifying the second point of the move vector. </p><p class="Heading-2">Remarks </p><p class="body">The two points you specify define a displacement vector indicating how far the given object is to be moved and in what direction.</p>

wzw393831667 发表于 2009-5-9 22:17:00

谢谢了但是没怎么看明白,能不能稍微详细的解释一下。或者在我的程序的基础上给出源代码呢?

wzw393831667 发表于 2009-5-10 10:50:00

lzh741206发表于2009-5-9 15:22:00static/image/common/back.gifMoves an object along a vector.See Also | ExampleSignature object.Move Point1, Point2 ObjectAll Drawing Objects, AttributeReferenceThe object or objects this method applies to. Po

<p></p>谢谢&nbsp; 但是你说的是move&nbsp; 我是问怎么offset?最好在我的程序基础上来点代码~~

雪山飞狐_lzh 发表于 2009-5-10 21:23:00

mspaceObj.offset(dist)

xuyajun1979 发表于 2009-5-14 19:13:00

<p>&nbsp;&nbsp;在前面加 Dim entobj As AcadEntity&nbsp;</p><p>在该语句后&nbsp;MsgBox "The objects in ModelSpace include: " &amp; mspaceObj.ObjectName, vbInformation, "Count Example"<br/></p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 加 Set entobj = mspaceObj<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entobj.Offset (-5)<br/>-5为偏移量</p>

wzw393831667 发表于 2009-5-16 10:53:00

<p>已解决</p>

lifefun 发表于 2012-11-7 16:59:54

不知到沿着直线偏移文字怎么弄的
页: [1]
查看完整版本: [求助]怎么将cad中的直线偏移一定距离