CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

Turns 属性 (ActiveX)

2024-5-18 18:22| 发布者: admin| 查看: 77| 评论: 0|原作者: admin|来自: AutoCAD

Turns 属性 (ActiveX)

指定螺旋线的圈数。

支持的平台:仅限 Windows

签名

VBA:

object.Turns
对象

类型:螺旋

此属性应用于的对象。

属性值

只读:

类型:ACAD_NOUNITS

圈数。

言论

没有其他评论。

例子

VBA:

Sub Example_Helix_BaseRadius()
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_HELIX")
    Dim mode As Integer
    
    AppActivate ThisDrawing.Application.Caption
    
    ssetObj.SelectOnScreen
    
    Dim obj As AcadEntity
    Dim helix As AcadHelix
    Dim helixBaseRadius As Double
    Dim objName As String
    For Each obj In ssetObj
        objName = obj.ObjectName
            If TypeOf obj Is AcadHelix Then
            Set helix = obj
            helix.BaseRadius = helix.BaseRadius * 2
            MsgBox "Baseradius of helix is doubled to " & helix.BaseRadius * 2
            End If
    Next
    ssetObj.Delete
End Sub

Sub Example_Helix_TopRadius()
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_HELIX")
    Dim mode As Integer
    
    AppActivate ThisDrawing.Application.Caption
    
    ssetObj.SelectOnScreen
    
    Dim obj As AcadEntity
    Dim helix As AcadHelix
    Dim helixBaseRadius As Double
    Dim objName As String
    For Each obj In ssetObj
        objName = obj.ObjectName
            If TypeOf obj Is AcadHelix Then
            Set helix = obj
            helix.TopRadius = helix.TopRadius * 0.5
            MsgBox "Top radius of helix is halved to " & helix.TopRadius * 0.5
            End If
    Next
    ssetObj.Delete
End Sub

Sub Example_Helix_Direction()
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_HELIX")
    Dim mode As Integer
    
    AppActivate ThisDrawing.Application.Caption
    
    ssetObj.SelectOnScreen
    
    Dim obj As AcadEntity
    Dim helix As AcadHelix
    Dim helixBaseRadius As Double
    Dim objName As String
    For Each obj In ssetObj
        objName = obj.ObjectName
            If TypeOf obj Is AcadHelix Then
            Set helix = obj
            If helix.Twist = acCCW Then
                helix.Twist = acCW
            Else
                helix.Twist = acCCW
            End If
            MsgBox "Direction is reversed"
            End If
    Next
    ssetObj.Delete
End Sub

Sub Example_Helix_Height()
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_HELIX")
    Dim mode As Integer
    
    AppActivate ThisDrawing.Application.Caption
    
    ssetObj.SelectOnScreen
    
    Dim obj As AcadEntity
    Dim helix As AcadHelix
    Dim helixBaseRadius As Double
    Dim objName As String
    For Each obj In ssetObj
        objName = obj.ObjectName
            If TypeOf obj Is AcadHelix Then
            Set helix = obj
            helix.Constrain = acHeight
            helix.height = helix.height * 2
            MsgBox "Height doubled"
            End If
    Next
    ssetObj.Delete
End Sub

Sub Example_Helix_Turns()
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_HELIX")
    Dim mode As Integer
    
    AppActivate ThisDrawing.Application.Caption
    
    ssetObj.SelectOnScreen
    
    Dim obj As AcadEntity
    Dim helix As AcadHelix
    Dim helixBaseRadius As Double
    Dim objName As String
    For Each obj In ssetObj
        objName = obj.ObjectName
            If TypeOf obj Is AcadHelix Then
            Set helix = obj
            helix.Constrain = acTurns
            helix.Turns = helix.Turns * 2
            MsgBox "Turns doubled"
            End If
    Next
    ssetObj.Delete
End Sub

Sub Example_Helix_TurnHeight()
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_HELIX")
    Dim mode As Integer
    
    AppActivate ThisDrawing.Application.Caption
    
    ssetObj.SelectOnScreen
    
    Dim obj As AcadEntity
    Dim helix As AcadHelix
    Dim helixBaseRadius As Double
    Dim objName As String
    For Each obj In ssetObj
        objName = obj.ObjectName
            If TypeOf obj Is AcadHelix Then
            Set helix = obj
            helix.Constrain = acTurnHeight
            helix.TurnHeight = helix.TurnHeight * 2
            MsgBox "Turns height doubled"
            End If
    Next
    ssetObj.Delete
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_Helix_BaseRadius()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq ssetObj (vla-Add (vla-get-SelectionSets doc) "TEST_HELIX"))
    (vla-SelectOnScreen ssetObj)
    
    (vlax-for obj ssetObj
        (setq objName (vla-get-ObjectName obj))
        (if (= objName "AcDbHelix")
            (progn
                (setq helix obj)
                (vla-put-BaseRadius helix (* (vla-get-BaseRadius helix) 2))
                (alert (strcat "Baseradius of helix is doubled to " (rtos (vla-get-BaseRadius helix) 2)))
            )
        )
    )
    (vla-Delete ssetObj)
)

(defun c:Example_Helix_TopRadius()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq ssetObj (vla-Add (vla-get-SelectionSets doc) "TEST_HELIX"))
    (vla-SelectOnScreen ssetObj)
    
    (vlax-for obj ssetObj
        (setq objName (vla-get-ObjectName obj))
        (if (= objName "AcDbHelix")
            (progn
                (setq helix obj)
                (vla-put-TopRadius helix (* (vla-get-TopRadius helix) 0.5))
                (alert (strcat "Top radius of helix is halved to " (rtos (vla-get-TopRadius helix) 2)))
            )
        )
    )
    (vla-Delete ssetObj)
)

(defun c:Example_Helix_Direction()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq ssetObj (vla-Add (vla-get-SelectionSets doc) "TEST_HELIX"))
    (vla-SelectOnScreen ssetObj)
    
    (vlax-for obj ssetObj
        (setq objName (vla-get-ObjectName obj))
        (if (= objName "AcDbHelix")
            (progn
                (setq helix obj)
	        (if (= (vla-get-Twist helix) acCCW)
	            (vla-put-Twist helix acCW)
	            (vla-put-Twist helix acCCW)
	        )
                (alert "Direction is reversed")
            )
        )
    )
    (vla-Delete ssetObj)
)

(defun c:Example_Helix_Height()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq ssetObj (vla-Add (vla-get-SelectionSets doc) "TEST_HELIX"))
    (vla-SelectOnScreen ssetObj)
    
    (vlax-for obj ssetObj
        (setq objName (vla-get-ObjectName obj))
        (if (= objName "AcDbHelix")
            (progn
                (setq helix obj)
                (vla-put-Constrain helix acHeight)
                (vla-put-Height helix (* (vla-get-Height helix) 2))
                (alert "Height doubled")
            )
        )
    )
    (vla-Delete ssetObj)
)

(defun c:Example_Helix_Turns()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq ssetObj (vla-Add (vla-get-SelectionSets doc) "TEST_HELIX"))
    (vla-SelectOnScreen ssetObj)
    
    (vlax-for obj ssetObj
        (setq objName (vla-get-ObjectName obj))
        (if (= objName "AcDbHelix")
            (progn
                (setq helix obj)
                (vla-put-Constrain helix acTurns)
                (vla-put-Turns helix (* (vla-get-Turns helix) 2))
                (alert "Turns doubled")
            )
        )
    )
    (vla-Delete ssetObj)
)

(defun c:Example_Helix_TurnHeight()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq ssetObj (vla-Add (vla-get-SelectionSets doc) "TEST_HELIX"))
    (vla-SelectOnScreen ssetObj)
    
    (vlax-for obj ssetObj
        (setq objName (vla-get-ObjectName obj))
        (if (= objName "AcDbHelix")
            (progn
                (setq helix obj)
                (vla-put-Constrain helix acTurnHeight)
                (vla-put-TurnHeight helix (* (vla-get-TurnHeight helix) 2))
                (alert "Turns height doubled")
            )
        )
    )
    (vla-Delete ssetObj)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2024-12-15 12:34

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部