乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 35|回复: 5

[编程交流] vlax-put-property att 'Te

[复制链接]

18

主题

111

帖子

93

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 15:24:43 | 显示全部楼层 |阅读模式
Dear coders,
 
Just want to set simple property using LISP
but getting different errors,
 
i want to set this property after i added an new attdef into my dwg using vla-addattribute syntax
 
Any an idea how to set this?
 
I try to set this value
_$ ins1
(0.0 0.0 0.0)
 
; error: Automation Error. Not applicable
_$ (vlax-put-property att 'Alignment prop1)
nil
_$ (vlax-put-property att 'TextAlignmentPoint (vlax-3D-point ins1))   
; error: Automation Error. Not applicable
_$ (vlax-3D-point ins1)
#
_$ (vlax-put-property att 'TextAlignmentPoint (vlax-3D-point ins1))
; error: Automation Error. Not applicable
_$ ins1
(0.0 0.0 0.0)
_$ (vlax-put-property att 'TextAlignmentPoint ins1)
; error: lisp value has no coercion to VARIANT with this type:  (0.0 0.0 0.0)
回复

使用道具 举报

18

主题

111

帖子

93

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 15:42:58 | 显示全部楼层
Even getting the prop and resetting it fails
 
_$ (vlax-get-property att 'TextAlignmentPoint)
#
_$ (setq test (vlax-get-property att 'TextAlignmentPoint))
#
_$ (vlax-put-property att 'TextAlignmentPoint test)
; error: Automation Error. Not applicable
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 15:54:27 | 显示全部楼层
maybe this helps :
 
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-ActiveX/files/GUID-27030E1C-6480-4A64-BE0A-E72C1FFF2023-htm.html
 
or
 
  1. ;;---------------=={ Match Text Properties }==----------------;;;;                                                            ;;;;  Prompts for a selection of Text, MText, Attribute, or     ;;;;  Attribute Definition object to use as property source,    ;;;;  then proceed to match those properties listed for similar ;;;;  objects selected thereafter.                              ;;;;------------------------------------------------------------;;;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;;;------------------------------------------------------------;;(defun c:MTP nil (c:MatchTextProps))(defun c:MatchTextProps ( / *error* _StartUndo _EndUndo _GetTextInsertion _PutTextInsertion Props doc entity object ss ) (vl-load-com) ;; © Lee Mac 2010 (setq Props  '(    Alignment    AttachmentPoint    BackgroundFill    Backward    DrawingDirection    Height    Layer    LineSpacingDistance    LineSpacingFactor    LineSpacingStyle    Linetype    LinetypeScale    Lineweight    ObliqueAngle    Rotation    ScaleFactor    StyleName   ; TextString    Thickness    UpsideDown    Width   ) ) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (defun *error* ( msg )   (if doc (_EndUndo doc)) (if mutt (setvar 'NOMUTT mutt))   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")       (princ (strcat "\n** Error: " msg " **")))   (princ) ) (defun _StartUndo ( doc ) (_EndUndo doc)   (vla-StartUndoMark doc) ) (defun _EndUndo ( doc )   (if (= 8 (logand 8 (getvar 'UNDOCTL)))     (vla-EndUndoMark doc)   ) ) (defun _GetTextInsertion ( object )   (vlax-get-property object     (if       (or         (eq "AcDbMText" (vla-get-ObjectName object))         (vl-position (vla-get-Alignment object)           (list acAlignmentLeft acAlignmentFit acAlignmentAligned)         )       )       'InsertionPoint       'TextAlignmentPoint     )   ) ) (defun _PutTextInsertion ( object point )   (vlax-put-property object     (if       (or         (eq "AcDbMText" (vla-get-ObjectName object))         (vl-position (vla-get-Alignment object)           (list acAlignmentLeft acAlignmentFit acAlignmentAligned)         )       )       'InsertionPoint       'TextAlignmentPoint     )     point   ) ) (if   (and     (setq entity       (LM:Selectif         (lambda ( x )           (wcmatch (cdr (assoc 0 (entget x))) "TEXT,MTEXT,ATTRIB,ATTDEF")         )         nentsel "\nSelect Source Object: "       )     )     (progn       (setq mutt (getvar 'NOMUTT))       (setvar 'NOMUTT 1)              (princ (strcat "\nSelect Destination " (cdr (assoc 0 (entget entity))) " objects: "))       (setq object (vlax-ename->vla-object entity)         ss          (ssget "_:L"            (list              (assoc 0 (entget entity))            )          )       )       (setvar 'NOMUTT mutt) ss     )   )   (     (lambda ( i values / entity obj )       (_StartUndo doc)              (while (setq entity (ssname ss (setq i (1+ i))))         (setq obj (vlax-ename->vla-object entity))         (mapcar           (function             (lambda ( prop value )               (if                 (vl-catch-all-error-p                   (vl-catch-all-apply                     (function                       (lambda nil                         (if (and (vlax-property-available-p obj prop t) value)                           (if (vl-position prop '(Alignment AttachmentPoint))                             (                               (lambda ( insertion )                                 (vlax-put-property obj prop value)                                 (_PutTextInsertion obj insertion)                               )                               (_GetTextInsertion obj)                             )                             (vlax-put-property obj prop value)                           )                         )                       )                     )                   )                 )                 (princ (strcat "\n** Error Applying Property: " Prop " **"))               )             )           )           Props Values         )       )       (_EndUndo doc)     )     -1     (mapcar       (function         (lambda ( prop )           (if (vlax-property-available-p object prop)             (vlax-get-property object prop)           )         )       )       Props     )   ) ) (princ));;---------------------=={ Select if }==----------------------;;;;                                                            ;;;;  Continuous selection prompts until the predicate function ;;;;  foo is validated                                          ;;;;------------------------------------------------------------;;;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;;;------------------------------------------------------------;;;;  Arguments:                                                ;;;;  foo - optional predicate function taking ename argument   ;;;;  fun - selection function to invoke                        ;;;;  str - prompt string                                       ;;;;------------------------------------------------------------;;;;  Returns:  selected entity ename if successful, else nil   ;;;;------------------------------------------------------------;;(defun LM:Selectif ( foo fun str / e ) ;; © Lee Mac 2010 (while   (progn (setq e (car (fun str)))           (cond       ( (eq 'ENAME (type e))         (if (and foo (not (foo e)))           (princ "\n** Invalid Object Selected **")         )       )     )   ) ) e)
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 16:06:17 | 显示全部楼层
 
If the Alignment property of single-line text or single-line attributes is set to Left (equivalently DXF groups 72 & 73 both set to 0), then the position of the text or attribute is instead determined by the InsertionPoint property (or DXF group 10); if the justification is anything other than Left, then the position is determined by the TextAlignmentPoint property (or DXF group 11).
 
This behaviour is clearly described in the 'Remarks' section of the documentation for the TextAlignmentPoint property:
 
回复

使用道具 举报

18

主题

111

帖子

93

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 16:17:16 | 显示全部楼层
I found the issue
For some strange reason the attdef i have seems to be made out of MTEXT
It only has the justification options you see with MTEXT
I try to set a value that does not exist for the mtext justification
 
Just wonder how it is possible to end up with attdef that has same justification as mtext
回复

使用道具 举报

18

主题

111

帖子

93

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 16:31:12 | 显示全部楼层
https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-Core/files/GUID-5C99524B-B5BB-4067-AE18-BD3575F29DBF-htm.html
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-14 21:05 , Processed in 0.507581 second(s), 64 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表