Author Topic: Leading zero removal from specific attributes  (Read 1160 times)

0 Members and 1 Guest are viewing this topic.

Biscuits

  • Swamp Rat
  • Posts: 502
Leading zero removal from specific attributes
« on: May 25, 2016, 11:11:06 AM »
Using Autocad 2013 on Windows 7 Pro

I'm really stumped on this one. I have  2 titleblocks:
"A" with attributes "2010Title" or "2014Title" with tag names "pg1"or "pg" or "PG_NO"
"B" with attributes "2014Title2" "2014Title2" with tag names "pg1"or "pg" or "PG_NO"

in all cases I need to remove the leading zero for our page numbers
(within the attributes applied to the above tags)

I've tried several ideas and end up hitting a wall every time.
Any ideas or suggestions?
I would post what I have so far, but it's just garbage.
Thanks

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Leading zero removal from specific attributes
« Reply #1 on: May 25, 2016, 12:09:12 PM »
When you say:

"A" with attributes "2010Title" or "2014Title" with tag names "pg1"or "pg" or "PG_NO"
"B" with attributes "2014Title2" "2014Title2" with tag names "pg1"or "pg" or "PG_NO"

What are '2010Title' etc.?

I understand that you have block "A" & block "B" with attribute tags "pg1"or "pg" or "PG_NO", but I don't see what "2010Title", "2014Title" are referring to.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Leading zero removal from specific attributes
« Reply #2 on: May 25, 2016, 12:11:37 PM »
Assuming the blocks are not dynamic:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / i s )
  2.     (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "A,B") (66 . 1))))
  3.         (repeat (setq i (sslength s))
  4.             (foreach a (vlax-invoke (vlax-ename->vla-object (ssname s (setq i (1- i)))) 'getattributes)
  5.                 (if (wcmatch (strcase (vla-get-tagstring a) t) "pg,pg1,pg_no")
  6.                     (vla-put-textstring a (vl-string-left-trim "0" (vla-get-textstring a)))
  7.                 )
  8.             )
  9.         )
  10.     )
  11.     (princ)
  12. )

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Leading zero removal from specific attributes
« Reply #3 on: May 25, 2016, 02:09:07 PM »
Perfect..........you make this stuff look too easy.
Thanks a bunch. I owe you another cold one!

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Leading zero removal from specific attributes
« Reply #4 on: May 25, 2016, 05:45:54 PM »
No worries!  :-)