Jump to content

Renumbering block atributte tags


Recommended Posts

Posted (edited)

I know you want to reorder the values for PNUM but if you have multiple copies of the block and PNUM has the same value then it stands to reason that any routine that is used to renumber the blocks will have to do it based upon the value of the X/Y coordinate.

Edited by ReMark
  • Replies 64
  • Created
  • Last Reply

Top Posters In This Topic

  • Kevin v/d Berg

    22

  • ReMark

    17

  • Tharwat

    14

  • Lee Mac

    7

Popular Days

Top Posters In This Topic

Posted

ad first i want to thank you for taking he time to under stand me

and nou i'm ganne dicribe it best as i can

and plase dont be botert by mij bad englich it snot mij first langit sen i'm having a bi t of a hadace

Posted

i have a libary in whitch each block has its own properties i usely copy from this libary and if thats done o have my foundation plan the only thing is the PNUM isint in a logiacal folowop becaus its like all value 1

 

i want to select a window en then it has to atomaticly renumer the pillers starting whit 1 and im this particular case end whit 300

i want to have the chois to select a left to right or a top to botum dyrection like folowing an x or Y

 

so that at the and i have an plan whit a logical number setup i hope this is axplination inoph

 

 

i used to have a progam cald matrix cad that had this fuction it was caled renumber, only matrix cad does not work whit the new autocad

Posted

The answer is easy. Update to the new version of Matrix Cad. Problem solved. No programming required.

Posted

the new matrix cad works rubish it ads almoost a 70 % chance to a fatel error

and half the original progam of auto cad wount work

 

i wich it was that easy

 

yes baying a progam is an optien but i persenely think its best to stic to the original autocad progam

and give it this one lisp

 

 

i was hoping peopel like lee mac could help me wrhite such a lisp i know alot of poepel would like it

Posted

Why is this thread 5 pages long?! I should imagine the OP is pulling his hair out by now...

 

From the first post, if I've understood correctly, the OP wishes to renumber his attributes in rows from left-to-right, or in columns from bottom-to-top.

 

I haven't bothered to read to whole thread, but this is how I understand the request:

 

[color=GREEN];; ReNumber Attributes  -  Lee Mac  -  2011  -  www.lee-mac.com[/color]

([color=BLUE]defun[/color] c:ReNumAtts ( [color=BLUE]/[/color] att blk ent enx inc ins lst sel tag )

   ([color=BLUE]setq[/color] blk [color=MAROON]"RK_PR_1"[/color] [color=GREEN];; Block Name[/color]
         tag [color=MAROON]"PNUM"[/color]    [color=GREEN];; Attribute Tag[/color]
         tag ([color=BLUE]strcase[/color] tag)
   )

   ([color=BLUE]defun[/color] LM:GroupByFunction ( lst fun [color=BLUE]/[/color] tmp1 tmp2 x1 )
       ([color=BLUE]if[/color] ([color=BLUE]setq[/color] x1 ([color=BLUE]car[/color] lst))
           ([color=BLUE]progn[/color]
               ([color=BLUE]foreach[/color] x2 ([color=BLUE]cdr[/color] lst)
                   ([color=BLUE]if[/color] (fun x1 x2)
                       ([color=BLUE]setq[/color] tmp1 ([color=BLUE]cons[/color] x2 tmp1))
                       ([color=BLUE]setq[/color] tmp2 ([color=BLUE]cons[/color] x2 tmp2))
                   )
               )
               ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] x1 tmp1) (LM:GroupByFunction tmp2 fun))
           )
       )
   )

   ([color=BLUE]if[/color] ([color=BLUE]setq[/color] sel ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"INSERT"[/color]) '(66 . 1) ([color=BLUE]cons[/color] 2 blk))))
       ([color=BLUE]progn[/color]
           ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] inc ([color=BLUE]sslength[/color] sel))
               ([color=BLUE]setq[/color] ent ([color=BLUE]ssname[/color] sel ([color=BLUE]setq[/color] inc ([color=BLUE]1-[/color] inc)))
                     ins ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 10 ([color=BLUE]entget[/color] ent)))
                     att [color=BLUE]nil[/color]
               )
               ([color=BLUE]while[/color]
                   ([color=BLUE]and[/color]
                       ([color=BLUE]null[/color] att)
                       ([color=BLUE]eq[/color] [color=MAROON]"ATTRIB"[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 0 ([color=BLUE]setq[/color] enx ([color=BLUE]entget[/color] ([color=BLUE]setq[/color] ent ([color=BLUE]entnext[/color] ent)))))))
                   )
                   ([color=BLUE]if[/color] ([color=BLUE]eq[/color] tag ([color=BLUE]strcase[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 enx))))
                       ([color=BLUE]setq[/color] att enx)
                   )
               )
               ([color=BLUE]if[/color] att ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] ([color=BLUE]list[/color] ins att) lst)))
           )
           ([color=BLUE]setq[/color] inc 0)
           ([color=BLUE]foreach[/color] row
               ([color=BLUE]vl-sort[/color] (LM:GroupByFunction lst ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]equal[/color] ([color=BLUE]cadar[/color] a) ([color=BLUE]cadar[/color] b) 0.1)))
                   ([color=BLUE]function[/color]
                       ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]>[/color] ([color=BLUE]cadaar[/color] a) ([color=BLUE]cadaar[/color] b)))
                   )
               )
               ([color=BLUE]foreach[/color] item ([color=BLUE]vl-sort[/color] row ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]<[/color] ([color=BLUE]caar[/color] a) ([color=BLUE]caar[/color] b)))))
                   ([color=BLUE]entmod[/color]
                       ([color=BLUE]subst[/color]
                           ([color=BLUE]cons[/color]  1 ([color=BLUE]itoa[/color] ([color=BLUE]setq[/color] inc ([color=BLUE]1+[/color] inc))))
                           ([color=BLUE]assoc[/color] 1 ([color=BLUE]cadr[/color] item))
                           ([color=BLUE]cadr[/color] item)
                       )
                   )
               )
           )
       )
   )
   ([color=BLUE]princ[/color])
)
([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color])

 

The answer is easy. Update to the new version of Matrix Cad. Problem solved. No programming required.

 

That's ridiculous. Update the entire application just to renumber some attributes?

Posted

Furthermore, I can't understand the complaints about the drawings?

 

In the third post, the OP has uploaded an example of the Block itself, and an example drawing in which the block is inserted - what more do you want?! :shock:

Posted

a snapshot/picture/image of the final product will clear everything up for you guys.

 

That will overcome the language barrier ;)

Posted (edited)

Jeez Lee we're sorry. Removed comment.

 

I only said the OP posted an attributed block about five times. Yep, it was five times (post #9, 14, 21, 26 and 29).

Edited by ReMark
Posted

lee mac the last time i found this lisp id dident work perfect some numbers were scrabeld when i addet alot of blokc's but this time its works perfect !thanks for stepping in !

 

one questin is it posebleto ad a choise to select the direction in wich i want to go

 

\this is a left to tigt top to bottum is it pasbel to ad a choise lijke botm to top then left to rigt and such or is this a big change

Posted
Maybe if you hadn't been such a slacker you could have solved the OP's problem by post number 2.

 

I'm sincerely hoping that was in jest.

 

Hell, I only said the OP posted an attributed block about five times.

 

My post wasn't directed only at you ReMark.

 

Yes, I wanted the OP to buy an updated version of the "magic" program he was using so it would stimulate the economy and save the European Union.

 

And there I was thinking we were here to offer sensible solutions. :roll:

Posted

Yes, it was said it jest.

 

I haven't looked at the routine. Is the renumbering based upon the X/Y coordinate of the block?

Posted
I haven't looked at the routine. Is the renumbering based upon the X/Y coordinate of the block?

 

Yes, currently in rows, left-to-right.

Posted
lee mac the last time i found this lisp id dident work perfect some numbers were scrabeld when i addet alot of blokc's but this time its works perfect !thanks for stepping in !

 

one questin is it posebleto ad a choise to select the direction in wich i want to go

 

\this is a left to tigt top to bottum is it pasbel to ad a choise lijke botm to top then left to rigt and such or is this a big change

 

Not too much extra code, try this:

 

[color=GREEN];; ReNumber Attributes  -  Lee Mac  -  2011  -  www.lee-mac.com[/color]

([color=BLUE]defun[/color] c:ReNumAtts ( [color=BLUE]/[/color] att blk ent enx inc ins lst sel srt tag )

   ([color=BLUE]setq[/color] blk [color=MAROON]"RK_PR_1"[/color] [color=GREEN];; Block Name[/color]
         tag [color=MAROON]"PNUM"[/color]    [color=GREEN];; Attribute Tag[/color]
         tag ([color=BLUE]strcase[/color] tag)
   )

   ([color=BLUE]defun[/color] LM:GroupByFunction ( lst fun [color=BLUE]/[/color] tmp1 tmp2 x1 )
       ([color=BLUE]if[/color] ([color=BLUE]setq[/color] x1 ([color=BLUE]car[/color] lst))
           ([color=BLUE]progn[/color]
               ([color=BLUE]foreach[/color] x2 ([color=BLUE]cdr[/color] lst)
                   ([color=BLUE]if[/color] (fun x1 x2)
                       ([color=BLUE]setq[/color] tmp1 ([color=BLUE]cons[/color] x2 tmp1))
                       ([color=BLUE]setq[/color] tmp2 ([color=BLUE]cons[/color] x2 tmp2))
                   )
               )
               ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] x1 tmp1) (LM:GroupByFunction tmp2 fun))
           )
       )
   )

   ([color=BLUE]if[/color] ([color=BLUE]setq[/color] sel ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"INSERT"[/color]) '(66 . 1) ([color=BLUE]cons[/color] 2 blk))))
       ([color=BLUE]progn[/color]
           ([color=BLUE]initget[/color] [color=MAROON]"LTR RTL TTB BTT"[/color])
           ([color=BLUE]setq[/color] *dir*
               ([color=BLUE]cond[/color]
                   (   ([color=BLUE]getkword[/color]
                           ([color=BLUE]strcat[/color] [color=MAROON]"\nDirection? [LTR/RTL/TTB/BTT] <"[/color]
                               ([color=BLUE]setq[/color] *dir* ([color=BLUE]cond[/color] ( *dir* ) ([color=MAROON]"LTR"[/color]))) [color=MAROON]">: "[/color]
                           )
                       )
                   )
                   (   *dir*   )
               )
           )
           ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] inc ([color=BLUE]sslength[/color] sel))
               ([color=BLUE]setq[/color] ent ([color=BLUE]ssname[/color] sel ([color=BLUE]setq[/color] inc ([color=BLUE]1-[/color] inc)))
                     ins ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 10 ([color=BLUE]entget[/color] ent)))
                     att [color=BLUE]nil[/color]
               )
               ([color=BLUE]while[/color]
                   ([color=BLUE]and[/color]
                       ([color=BLUE]null[/color] att)
                       ([color=BLUE]eq[/color] [color=MAROON]"ATTRIB"[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 0 ([color=BLUE]setq[/color] enx ([color=BLUE]entget[/color] ([color=BLUE]setq[/color] ent ([color=BLUE]entnext[/color] ent)))))))
                   )
                   ([color=BLUE]if[/color] ([color=BLUE]eq[/color] tag ([color=BLUE]strcase[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 enx))))
                       ([color=BLUE]setq[/color] att enx)
                   )
               )
               ([color=BLUE]if[/color] att ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] ([color=BLUE]list[/color] ins att) lst)))
           )
           ([color=BLUE]setq[/color] inc 0)
           ([color=BLUE]foreach[/color] row
               ([color=BLUE]apply[/color] '[color=BLUE]vl-sort[/color]
                   ([color=BLUE]cond[/color]
                       (   ([color=BLUE]member[/color] *dir* '([color=MAROON]"LTR"[/color] [color=MAROON]"RTL"[/color]))
                           ([color=BLUE]if[/color] ([color=BLUE]eq[/color] [color=MAROON]"LTR"[/color] *dir*)
                               ([color=BLUE]setq[/color] srt ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]<[/color] ([color=BLUE]caar[/color] a) ([color=BLUE]caar[/color] b)))))
                               ([color=BLUE]setq[/color] srt ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]>[/color] ([color=BLUE]caar[/color] a) ([color=BLUE]caar[/color] b)))))
                           )
                           ([color=BLUE]list[/color]
                               (LM:GroupByFunction lst ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]equal[/color] ([color=BLUE]cadar[/color] a) ([color=BLUE]cadar[/color] b) 0.1)))
                               ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]>[/color] ([color=BLUE]cadaar[/color] a) ([color=BLUE]cadaar[/color] b))))
                           )
                       )
                       (   ([color=BLUE]member[/color] *dir* '([color=MAROON]"TTB"[/color] [color=MAROON]"BTT"[/color]))
                           ([color=BLUE]if[/color] ([color=BLUE]eq[/color] [color=MAROON]"TTB"[/color] *dir*)
                               ([color=BLUE]setq[/color] srt ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]>[/color] ([color=BLUE]cadar[/color] a) ([color=BLUE]cadar[/color] b)))))
                               ([color=BLUE]setq[/color] srt ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]<[/color] ([color=BLUE]cadar[/color] a) ([color=BLUE]cadar[/color] b)))))
                           )
                           ([color=BLUE]list[/color]
                               (LM:GroupByFunction lst ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]equal[/color] ([color=BLUE]caar[/color] a) ([color=BLUE]caar[/color] b) 0.1)))
                               ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]<[/color] ([color=BLUE]caaar[/color] a) ([color=BLUE]caaar[/color] b))))
                           )
                       )
                   )
               )
               ([color=BLUE]foreach[/color] item ([color=BLUE]vl-sort[/color] row srt)
                   ([color=BLUE]entmod[/color]
                       ([color=BLUE]subst[/color]
                           ([color=BLUE]cons[/color]  1 ([color=BLUE]itoa[/color] ([color=BLUE]setq[/color] inc ([color=BLUE]1+[/color] inc))))
                           ([color=BLUE]assoc[/color] 1 ([color=BLUE]cadr[/color] item))
                           ([color=BLUE]cadr[/color] item)
                       )
                   )
               )
           )
       )
   )
   ([color=BLUE]princ[/color])
)
([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color])

Posted

lee mac is it posible to make the RK_(PR_1) the PR_-1 lijke a variable becase i also have a RK_PR_2 and a RK_PV_1

Posted

Lee:

 

I removed the comment. My apologies again.

 

Confirmed. I personally mentioned it was an attributed block (even listed the attributes in one post) five times.

 

I directed the OP to two of your previously written programs both of which he said did not fit his needs.

 

Post #24 - I mention "sequential numbering".

 

Post #41 - I mention basing a lisp routine on the X/Y coordinates since there were many instances of blocks having the same value for PNUM.

Posted

i sweer im don after this i dont want to waste you time any moor but thanks a 100 times

Posted (edited)

You're not wasting our time. Hang in there.

Edited by ReMark
Posted
lee mac is it posible to make the RK_(PR_1) the PR_-1 lijke a variable becase i also have a RK_PR_2 and a RK_PV_1

 

The block name is a variable that can be changed at the top of the code - variable 'blk'.

 

Lee:

 

I removed the comment. My apologies again.

 

No worries, we're cool.

 

Confirmed. I personally mentioned it was an attributed block (even listed the attributes in one post) five times.

 

As I say, my remarks weren't directly aimed at you - I was just frustrated that here we claim to offer the 'best free help for AutoCAD' and yet it seemed to take two pages of the thread for some to argue over whether the block was indeed attributed. :?

 

I directed the OP to two of your previously written programs both of which he said did not fit his needs.

 

Post #24 - I mention "sequential numbering".

 

Post #41 - I mention basing a lisp routine on the X/Y coordinates since there were many instances of blocks having the same value for PNUM.

 

As I say, I admittedly didn't read the entire thread - I was frustrated after the first two pages. Maybe I overreacted, but having understood the request from the first post, and clear example drawings from the third, I couldn't believe the thread had reached 5 pages with still no solution...

Posted (edited)

Personally I was just waiting for someone smarter than me (i.e. - Lee Mac) to come along and solve the problem.:lol:

Edited by ReMark

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