TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: amc.dicsac on April 28, 2017, 04:44:25 PM

Title: Change select all to select simple
Post by: amc.dicsac on April 28, 2017, 04:44:25 PM
Hi, how are you:

I have the following lisp that changes the height of all the texts, that are within the block. The problem is that it makes a total selection, I would like to change to a simple selection using ssget, I hope they can help me thanks.


Code - Auto/Visual Lisp: [Select]
  1. (defun ChangeAllTextAltura (Doc Alt / IsLo tempObjType)
  2.  (setq IsLo (if (= (vla-get-IsLayout Blk) :vlax-true) T nil))
  3.  (if (= (vla-get-IsXref Blk) :vlax-false)
  4.   (vlax-for Obj Blk
  5.    (setq tempObjType (vla-get-ObjectName Obj))
  6.    (cond
  7.     ((vl-position tempObjType '("AcDbText" "AcDbMText" "AcDbAttributeDefinition"))
  8.      (vla-put-Height Obj Alt)
  9.      (if (not IsLo)
  10.       (vla-put-Layer Obj "0")
  11.      )
  12.     )
  13.     ((wcmatch tempObjType "AcDb*Dimension")
  14.      (vla-put-Height Obj Alt)
  15.     )
  16.     ((= tempObjType "AcDbBlockReference")
  17.      (foreach Att (vlax-invoke Obj 'GetAttributes)
  18.       (vla-put-Height Att Alt)
  19.      )
  20.      (foreach Att (vlax-invoke Obj 'GetConstantAttributes)
  21.       (vla-put-Height Att Alt)
  22.      )
  23.     )
  24.    )
  25.   )
  26.  )
  27. )
  28. )



Code - Auto/Visual Lisp: [Select]
  1. (defun c:TH ()
  2. ([font=Verdana][size=2px]ChangeAllTextAltura [/size][/font] (vla-get-ActiveDocument (vlax-get-Acad-Object)) 0.15)
  3. (command "regenall")
Title: Re: Change select all to select simple
Post by: Chris on April 28, 2017, 09:11:45 PM
I dont think it will be that simple.  to select attributes within a block, you'd either have to explode the block or find some way to pass the cooridinate of selection point into the program and somehow associate the point with the attribute within the block.
Title: Re: Change select all to select simple
Post by: BIGAL on April 29, 2017, 09:48:20 PM
If I understand right you want to change say 1 attribute text, so just use bedit change the text, then attsync the blocks.
Title: Re: Change select all to select simple
Post by: Grrr1337 on April 30, 2017, 07:41:06 AM
You'll have to modify the subfunction a bit:

Code - Auto/Visual Lisp: [Select]
  1. ; (ChangeAllTextAltura (vla-get-ActiveDocument (vlax-get-Acad-Object)) 0.15 '("MyBlock1" "MyBlock2" "MyBlock3"))
  2. (defun ChangeAllTextAltura (Doc Alt ForBlocks / IsLo tempObjType)
  3.   (vlax-for Blk (vla-get-Blocks Doc)
  4.     (cond
  5.       ( (eq (vla-get-IsXref Blk) :vlax-true) )
  6.       ( (not (member (vla-get-Name Blk) ForBlocks)) )
  7.       (T (setq IsLo (= (vla-get-IsLayout Blk) :vlax-true))
  8.         (vlax-for Obj Blk
  9.           (setq tempObjType (vla-get-ObjectName Obj))
  10.           (cond
  11.             ( (vl-position tempObjType '("AcDbText" "AcDbMText" "AcDbAttributeDefinition"))
  12.               (vla-put-Height Obj Alt)
  13.               (if (not IsLo)
  14.                 (vla-put-Layer Obj "0")
  15.               )
  16.             )
  17.             ( (wcmatch tempObjType "AcDb*Dimension")
  18.               (vla-put-Height Obj Alt)
  19.             )
  20.             ( (= tempObjType "AcDbBlockReference")
  21.               (foreach Att (append (vlax-invoke Obj 'GetAttributes) (vlax-invoke Obj 'GetConstantAttributes))
  22.                 (vla-put-Height Att Alt)
  23.               )
  24.             )
  25.           )
  26.         )
  27.       )
  28.     )
  29.   )
  30. )