指定样条曲线的控制点。 支持的平台:仅窗口 属性值只读:不 类型:变体(双打数组) 样条的三维 WCS 控制点数组。 言论您可以使用属性找出样条有多少个控制点。NumberOfControlPoints 例子工 务 局: Sub Example_ControlPoints() ' This example creates a Spline object in model space, reads the control points ' of the Spline and then modifies the control points of the Spline. Dim splineObj As AcadSpline Dim startTan(0 To 2) As Double, endTan(0 To 2) As Double Dim fitPoints(0 To 8) As Double Dim UserMessage As String Dim ControlPoints As Variant Dim iCount As Long, iPoint As Integer ' Define the Spline object startTan(0) = 0.5: startTan(1) = 0.5: startTan(2) = 0 endTan(0) = 0.5: endTan(1) = 0.5: endTan(2) = 0 fitPoints(0) = 0: fitPoints(1) = 0: fitPoints(2) = 0 fitPoints(3) = 5: fitPoints(4) = 5: fitPoints(5) = 0 fitPoints(6) = 10: fitPoints(7) = 0: fitPoints(8) = 0 ' Create new Spline object Set splineObj = ThisDrawing.ModelSpace.AddSpline(fitPoints, startTan, endTan) ThisDrawing.Application.ZoomAll ' Display control points for this Spline GoSub DISPLAYPOINTS ' Modify control points for this Spline ControlPoints(0) = 3 splineObj.ControlPoints = ControlPoints ThisDrawing.Application.ZoomAll ' Display new control points for this Spline GoSub DISPLAYPOINTS Exit Sub DISPLAYPOINTS: ControlPoints = splineObj.ControlPoints ' Display in groups of three UserMessage = "" iPoint = 0 For iCount = 0 To UBound(ControlPoints) Step 3 iPoint = iPoint + 1 UserMessage = UserMessage & iPoint & ")" & vbTab UserMessage = UserMessage & ControlPoints(iCount) UserMessage = UserMessage & ", " & ControlPoints(iCount + 1) UserMessage = UserMessage & ", " & ControlPoints(iCount + 2) UserMessage = UserMessage & vbCrLf Next MsgBox "The " & splineObj.NumberOfControlPoints & " Spline control points are: " & vbCrLf & vbCrLf & UserMessage Return End Sub Visual LISP: (vl-load-com) (defun c:Example_ControlPoints() ;; This example creates a Spline object in model space, reads the control points ;; of the Spline and then modifies the control points of the Spline. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Define the Spline object (setq startTan (vlax-3d-point 0.5 0.5 0) endTan (vlax-3d-point 0.5 0.5 0) fitPoints (vlax-make-safearray vlax-vbDouble '(0 . 8))) (vlax-safearray-fill fitPoints '(0 0 0 5 5 0 10 0 0 ) ) ;; Create new Spline object (setq modelSpace (vla-get-ModelSpace doc)) (setq splineObj (vla-AddSpline modelSpace fitPoints startTan endTan)) (vla-ZoomAll acadObj) ;; Display control points for this Spline (setq ControlPoints (vlax-variant-value (vla-get-ControlPoints splineObj))) ;; Display in groups of three (setq UserMessage "" iPoint 0 iCount 0) (while (>= (vlax-safearray-get-u-bound ControlPoints 1) iCount) (setq iPoint (1+ iPoint)) (setq UserMessage (strcat UserMessage (itoa iPoint) ") " (rtos (nth iCount (vlax-safearray->list ControlPoints)) 2) ", " (rtos (nth (+ iCount 1) (vlax-safearray->list ControlPoints)) 2) ", " (rtos (nth (+ iCount 2) (vlax-safearray->list ControlPoints)) 2) "\n" ) ) (setq iCount (+ iCount 3)) ) (alert (strcat "The " (itoa (vla-get-NumberOfControlPoints splineObj)) " Spline control points are: " "\n\n" UserMessage)) ;; Modify control points for this Spline (setq newFitPoint (vlax-3d-point 8 2 0)) (vla-AddFitPoint splineObj 3 newFitPoint) (setq ControlPoints (vlax-variant-value (vla-get-ControlPoints splineObj))) (vla-ZoomAll acadObj) ;; Display new control points for this Spline (setq UserMessage "" iPoint 0 iCount 0) (while (>= (vlax-safearray-get-u-bound ControlPoints 1) iCount) (setq iPoint (1+ iPoint)) (setq UserMessage (strcat UserMessage (itoa iPoint) ") " (rtos (nth iCount (vlax-safearray->list ControlPoints)) 2) ", " (rtos (nth (+ iCount 1) (vlax-safearray->list ControlPoints)) 2) ", " (rtos (nth (+ iCount 2) (vlax-safearray->list ControlPoints)) 2) "\n" ) ) (setq iCount (+ iCount 3)) ) (alert (strcat "The " (itoa (vla-get-NumberOfControlPoints splineObj)) " Spline control points are: " "\n\n" UserMessage)) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:44
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.