DGRL 发表于 2022-7-5 15:24:43

vlax-put-property att 'Te

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)

DGRL 发表于 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 发表于 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
 

;;---------------=={ 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)

Lee Mac 发表于 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:
 

DGRL 发表于 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

DGRL 发表于 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
页: [1]
查看完整版本: vlax-put-property att 'Te