Jump to content

Block Attribute Change - Almost There?


GregGleason

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 🙂

Link to comment
Share on other sites

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

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...