明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3844|回复: 7

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

[复制链接]
发表于 2009-5-9 15:10:00 | 显示全部楼层 |阅读模式

以下是源程序:程序的目的是在有各种图形的cad图中,把直线选出来,之后再将直线偏移一定的距离。 现在我可以选出直线,但是不知道该怎么偏移。请大家帮下忙~不盛感激。

Dim acadDoc As Object
Dim acadApp As Object


Private Sub CmdTj_Click()

   
    MsgBox "There are " & acadDoc.Layers.Count & " layer(s) in the drawing."
    MsgBox "There are " & acadDoc.ModelSpace.Count & " object(s) in ModelSpace."

    Dim objCount As Integer
    Dim I As Integer
    objCount = acadDoc.ModelSpace.Count
   
    Dim mspaceObj As AcadObject

    For I = 0 To objCount - 1
     Set mspaceObj = acadDoc.ModelSpace.Item(I)
      If mspaceObj.ObjectName = "AcDbLine" Then
         MsgBox "The objects in ModelSpace include: " & mspaceObj.ObjectName, vbInformation, "Count Example"

      End If
    Next
End Sub

Private Sub Form_Load()
Set acadApp = GetObject(, "AutoCAD.Application")
Set acadDoc = acadApp.ActiveDocument
End Sub

发表于 2009-5-9 15:22:00 | 显示全部楼层

Moves an object along a vector.

MSITStore:C:\Program%20Files\AutoCAD%202008\help\acadauto.chm::/move_see_also.htm">See Also | MSITStore:C:\Program%20Files\AutoCAD%202008\help\acadauto.chm::/ex_move.htm">Example

Signature

object.Move Point1, Point2

Object

MSITStore:C:\Program%20Files\AutoCAD%202008\help\acadauto.chm::/all_drawing_objects.htm">All Drawing Objects, MSITStore:C:\Program%20Files\AutoCAD%202008\help\acadauto.chm::/idh_attributeref_object.htm">AttributeReference
The object or objects this method applies to.

Point1

Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the first point of the move vector.

Point2

Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the second point of the move vector.

Remarks

The two points you specify define a displacement vector indicating how far the given object is to be moved and in what direction.

 楼主| 发表于 2009-5-9 22:17:00 | 显示全部楼层
谢谢了  但是没怎么看明白,能不能稍微详细的解释一下。或者在我的程序的基础上给出源代码呢?
 楼主| 发表于 2009-5-10 10:50:00 | 显示全部楼层
lzh741206发表于2009-5-9 15:22:00Moves an object along a vector.See Also | ExampleSignature object.Move Point1, Point2 ObjectAll Drawing Objects, AttributeReferenceThe object or objects this method applies to. Po

谢谢  但是你说的是move  我是问怎么offset?最好在我的程序基础上来点代码~~
发表于 2009-5-10 21:23:00 | 显示全部楼层
mspaceObj.offset(dist)
发表于 2009-5-14 19:13:00 | 显示全部楼层

  在前面加 Dim entobj As AcadEntity 

在该语句后 MsgBox "The objects in ModelSpace include: " & mspaceObj.ObjectName, vbInformation, "Count Example"

        加 Set entobj = mspaceObj
        entobj.Offset (-5)
-5为偏移量

 楼主| 发表于 2009-5-16 10:53:00 | 显示全部楼层

已解决

发表于 2012-11-7 16:59:54 | 显示全部楼层
不知到沿着直线偏移文字怎么弄的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-29 06:57 , Processed in 0.163740 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表