基于按名称标识的模板、给定插入点、比例因子和旋转处创建 Shape 对象。 支持的平台:仅窗口 签名工 务 局: RetVal = object.AddShape(Name, InsertionPoint, ScaleFactor, Rotation) 返回值(RetVal)类型:形状 新创建的对象。Shape 言论在添加 Shape 对象之前,必须使用该方法加载包含所需形状的文件。LoadShapeFile 例子工 务 局: Sub Example_AddShape() ' This example creates a BAT shape from the ltypeshp.shx file. ' Load the shape file containing the shape you wish to create. ' Note: Replace the ltypeshp.shx file name ' with a valid shape file for your system. On Error GoTo ERRORHANDLER ThisDrawing.LoadShapeFile ("C:/Program Files/AutoCAD/Support/ltypeshp.shx") Dim shapeObj As AcadShape Dim shapeName As String Dim insertionPoint(0 To 2) As Double Dim scalefactor As Double Dim rotation As Double ' "diode" is defined in es.shx file shapeName = "BAT" insertionPoint(0) = 2#: insertionPoint(1) = 2#: insertionPoint(2) = 0# scalefactor = 1# rotation = 0# ' Radians ' Create the diode shape object in model space Set shapeObj = ThisDrawing.ModelSpace.AddShape(shapeName, insertionPoint, scalefactor, rotation) Exit Sub ERRORHANDLER: MsgBox "Cannot find the shape file.", , "AddShape Example" End Sub Visual LISP: (vl-load-com) (defun c:Example_AddShape() ;; This example creates a BAT shape from the ltypeshp.shx file. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Load the shape file containing the shape you wish to create. ;; Note: Replace the ltypeshp.shx file name ;; with a valid shape file for your system. (setq shapeFile ".\\ltypeshp.shx") (if (/= (findfile shapeFile) nil) (progn (vla-LoadShapeFile doc (findfile shapeFile)) ;; "diode" is defined in es.shx file (setq insertionPoint (vlax-3d-point 2 2 0) shapeName "BAT" scalefactor 1 rotation 0) ;; Radians ;; Create the diode shape object in model space (setq modelSpace (vla-get-ModelSpace doc)) (setq shapeObj (vla-AddShape modelSpace shapeName insertionPoint scalefactor rotation)) ) (alert "Cannot find the shape file.") ) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:22
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.