Jump to content
GregGleason

Block Attribute Change - Almost There?

Recommended Posts

GregGleason

I have a routine that almost works.

 

I have attributes that I want to move and the last attribute is a copy/move.

 

I want to change the attributes of that last copied ATTDEF (so it's just one object).  Namely, the Layer, Tag, Prompt, and Height

 

This is what I have so far:

 

(defun c:zzz ()
; (setvar 'osmode 16384)
   (if (setq ss1 (ssget "_C" '(15.3 1.3) '(15.2 1.2) '((0 . "ATTDEF"))))
      (command "_.MOVE" ss1 "" "_non" '(0. 0. 0.) "_non" '(0. 0.0832 0.))
      (alert "MTEXT Not Found")
   );; End of if
   (if (setq ss1 (ssget "_C" '(15.3 0.96) '(15.2 0.95) '((0 . "ATTDEF"))))
      (command "_.MOVE" ss1 "" "_non" '(0. 0. 0.) "_non" '(0. 0.1093 0.))
      (alert "MTEXT Not Found")
   );; End of if
   (if (setq ss1 (ssget "_C" '(15.3 1.10) '(15.2 1.09) '((0 . "ATTDEF"))))
      (command "_.COPY" ss1 "" "_non" '(0. 0. 0.) "_non" '(0. -0.1614 0.))
      (alert "MTEXT Not Found")
   );; End of if


  (if (setq ss (ssget "_C" '(15.3 0.93) '(15.2 0.92) '((0 . "ATTDEF"))))
  ; Change tag to "TITLE-3"
  ; Change prompt to "Title Line #3"
  ; Change layer to "_CBAR"
  ; Change height to 0.0938
  )
)

I am not sure how to change the attributes.

 

Am I close or do I have a ways to go?

 

Greg

Share this post


Link to post
Share on other sites
ronjonp
Posted (edited)

For your last attribute that is copied, use (entlast) to get the ename.

Then use:

(setq o (vlax-ename->vla-object (entlast)))

This will convert it to a vla-object and the properties within are fairly self explanatory.

Quote

; IAcadAttribute: AutoCAD Attribute Interface
; Property values:
;   Alignment = 0
;   Application (RO) = Exception occurred
;   Backward = 0
;   Constant = 0
;   Document (RO) = #<VLA-OBJECT IAcadDocument 000001e7a0c7ead8>
;   EntityTransparency = "ByLayer"
;   FieldLength = 0
;   Handle (RO) = "2AC"
;   HasExtensionDictionary (RO) = 0
;   Height = 0.125
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000001e055005f58>
;   InsertionPoint = (8.76264 0.740156 0.0)
;   Invisible = 0
;   Layer = "0"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   LockPosition = -1
;   Material = "ByLayer"
;   Mode = 16
;   MTextAttribute = 0
;   MTextAttributeContent = ""
;   MTextBoundaryWidth = 0.0
;   MTextDrawingDirection = 5
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 1086
;   ObjectName (RO) = "AcDbAttributeDefinition"
;   ObliqueAngle = 0.0
;   OwnerID (RO) = 1072
;   PlotStyleName = "ByLayer"
;   Preset = 0
;   PromptString = ""
;   Rotation = 0.0
;   ScaleFactor = 1.0
;   StyleName = "Standard"
;   TagString = "ASFF"
;   TextAlignmentPoint = (0.0 0.0 0.0)
;   TextGenerationFlag = 0
;   TextString = ""
;   Thickness = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 000001e055006bb0>
;   UpsideDown = 0
;   Verify = 0
;   Visible = -1

 

Edited by ronjonp

Share this post


Link to post
Share on other sites
GregGleason

Thanks ronjonp.  I don't understand these objects and how to get or place data into them.  Is there a link you could point me to?

Share this post


Link to post
Share on other sites
GregGleason

UPDATE:  I found a source and got some things happening.  Thanks for the point in the right direction ronjonp!

Share this post


Link to post
Share on other sites
GregGleason

The code that I added:

 

   (setq o (vlax-ename->vla-object (entlast)))
   (setq ts (vla-get-tagString o))
   (princ "\nTag String: ")                      ; Print notice
   (princ ts)                               ; Print insulation string
   (vla-put-tagString o "TITLE-3")
   (vla-put-PromptString o "Title Line #3")

Greg

Share this post


Link to post
Share on other sites
ronjonp
35 minutes ago, GregGleason said:

The code that I added:

 


   (setq o (vlax-ename->vla-object (entlast)))
   (setq ts (vla-get-tagString o))
   (princ "\nTag String: ")                      ; Print notice
   (princ ts)                               ; Print insulation string
   (vla-put-tagString o "TITLE-3")
   (vla-put-PromptString o "Title Line #3")

Greg

Glad you got it sorted 🙂

Share this post


Link to post
Share on other sites
BIGAL

If you see vla-get in example code then in most cases you can do the opposite a vla-put.

 

You will find Dumpit.lsp to be your friend. You can though investigate some vla-get objects even further using the (vlax-dump-object obj) which is like doing a entnext method.

 

This will dump all the attribute info for a selected block


(setq obj (vlax-ename->vla-object (car (entsel "\nPick a attribute block"))))
(foreach att (vlax-invoke obj 'getattributes)
(vlax-dump-object att)
)

DumpIt.LSP

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...