Author Topic: Make Sheet Index using obectDBX  (Read 68833 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #75 on: February 27, 2006, 03:55:44 PM »
What does the output list look like?  Once you have than, then sort it with vl-sort.  Post a sample returned list, and someone will be able to help better.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #76 on: February 27, 2006, 04:00:37 PM »
Tim

Thanks. Here is a typical output file.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #77 on: February 27, 2006, 04:04:37 PM »
I need to see the list.  Is it a list of lists? or does it just write to file from the code?  Let me look at the code one minutes.
I can't tell from your last post.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Make Sheet Index using obectDBX
« Reply #78 on: February 27, 2006, 04:07:37 PM »
This is the output as of what is posted.
Code: [Select]
(("DWG" . "UTB30930")
("TAB" . "---  Layout1  ---")
("TAB" . "---  Model  ---")
("ROOM-NO" . "01")
("FINISH" . "2-1-1-1")
("ROOM" . "Entry")
("ROOM-NO" . "05")
("FINISH" . "2-1-1-1")
("ROOM" . "Utility")
("ROOM-NO" . "04")
("FINISH" . "2-1-1-1")
("ROOM" . "Kitchen")
("ROOM-NO" . "08")
("FINISH" . "2-1(2)-1-1")
("ROOM" . "Bath")
("ROOM-NO" . "06")
("FINISH" . "1-1-1-1")
("ROOM" . "Closet")
("ROOM-NO" . "03")
("FINISH" . "1-1-1-1")
("ROOM" . "Dining")
("ROOM-NO" . "07")
("FINISH" . "1-1-1-1")
("ROOM" . "Bedroom")
("ROOM-NO" . "02")
("FINISH" . "1-1-1-1")
("ROOM" . "Living")
("ROOM-NO" . "12")
("FINISH" . "3-5-4-1")
("ROOM" . "Balcony")
("ROOM-NO" . "11")
("FINISH" . "3-6-4-3")
("ROOM" . "Storage")
("ROOM-NO" . "06")
("FINISH" . "1-1-1-1")
("ROOM" . "Closet")
("ROOM-NO" . "06")
("FINISH" . "1-1-1-1")
("ROOM" . "Closet")
("ROOM-NO" . "08")
("FINISH" . "2-1(2)-1-1")
("ROOM" . "Bath")
("ROOM-NO" . "07")
("FINISH" . "1-1-1-1")
("ROOM" . "Bedroom")
)

I changed the code to get this
Code: [Select]
(("DWG" . "UTB30930")
 ("TAB" . "---  Layout1  ---")
 ("TAB" . "---  Model  ---")
 (("ROOM-NO" . "01") ("FINISH" . "2-1-1-1") ("ROOM" . "Entry"))
 (("ROOM-NO" . "05") ("FINISH" . "2-1-1-1") ("ROOM" . "Utility"))
 (("ROOM-NO" . "04") ("FINISH" . "2-1-1-1") ("ROOM" . "Kitchen"))
 (("ROOM-NO" . "08") ("FINISH" . "2-1(2)-1-1") ("ROOM" . "Bath"))
 (("ROOM-NO" . "06") ("FINISH" . "1-1-1-1") ("ROOM" . "Closet"))
 (("ROOM-NO" . "03") ("FINISH" . "1-1-1-1") ("ROOM" . "Dining"))
 (("ROOM-NO" . "07") ("FINISH" . "1-1-1-1") ("ROOM" . "Bedroom"))
 (("ROOM-NO" . "02") ("FINISH" . "1-1-1-1") ("ROOM" . "Living"))
 (("ROOM-NO" . "12") ("FINISH" . "3-5-4-1") ("ROOM" . "Balcony"))
 (("ROOM-NO" . "11") ("FINISH" . "3-6-4-3") ("ROOM" . "Storage"))
 (("ROOM-NO" . "06") ("FINISH" . "1-1-1-1") ("ROOM" . "Closet"))
 (("ROOM-NO" . "06") ("FINISH" . "1-1-1-1") ("ROOM" . "Closet"))
 (("ROOM-NO" . "08") ("FINISH" . "2-1(2)-1-1") ("ROOM" . "Bath"))
 (("ROOM-NO" . "07") ("FINISH" . "1-1-1-1") ("ROOM" . "Bedroom"))
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #79 on: February 27, 2006, 04:13:51 PM »
Lunch time, but here is code to sort the second list by room numbers.
Code: [Select]
(vl-sort
 (cdddr tmpList)
 '(lambda (a b)
  (< (atoi (cdar a)) (atoi (cdar b)))
 )
)
Where tmpList is the list.  Here is the output.
Quote
Command: (vl-sort
(_>  (cdddr tmpList)
(_>  '(lambda (a b)
('(_>   (< (atoi (cdar a)) (atoi (cdar b)))
('(_>  )
(_> )
((("ROOM-NO" . "01") ("FINISH" . "2-1-1-1") ("ROOM" . "Entry")) (("ROOM-NO" .
"02") ("FINISH" . "1-1-1-1") ("ROOM" . "Living")) (("ROOM-NO" . "03") ("FINISH"
. "1-1-1-1") ("ROOM" . "Dining")) (("ROOM-NO" . "04") ("FINISH" . "2-1-1-1")
("ROOM" . "Kitchen")) (("ROOM-NO" . "05") ("FINISH" . "2-1-1-1") ("ROOM" .
"Utility")) (("ROOM-NO" . "06") ("FINISH" . "1-1-1-1") ("ROOM" . "Closet"))
(("ROOM-NO" . "06") ("FINISH" . "1-1-1-1") ("ROOM" . "Closet")) (("ROOM-NO" .
"06") ("FINISH" . "1-1-1-1") ("ROOM" . "Closet")) (("ROOM-NO" . "07") ("FINISH"
. "1-1-1-1") ("ROOM" . "Bedroom")) (("ROOM-NO" . "07") ("FINISH" . "1-1-1-1")
("ROOM" . "Bedroom")) (("ROOM-NO" . "08") ("FINISH" . "2-1(2)-1-1") ("ROOM" .
"Bath")) (("ROOM-NO" . "08") ("FINISH" . "2-1(2)-1-1") ("ROOM" . "Bath"))
(("ROOM-NO" . "11") ("FINISH" . "3-6-4-3") ("ROOM" . "Storage")) (("ROOM-NO" .
"12") ("FINISH" . "3-5-4-1") ("ROOM" . "Balcony")))
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Make Sheet Index using obectDBX
« Reply #80 on: February 27, 2006, 04:53:12 PM »
Thanks for the input Tim.

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #81 on: February 27, 2006, 05:04:35 PM »
Allen and Tim

Thanks. Perfect. This will give a good example to learn from....but right now my head hurts.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #82 on: February 27, 2006, 05:16:10 PM »
Thanks for the input Tim.

Sorry didn't have time to make it look purtty.  You're welcome.
Allen and Tim

Thanks. Perfect. This will give a good example to learn from....but right now my head hurts.

Gary

You're welcome also, for what little I did.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #83 on: February 27, 2006, 05:18:31 PM »
Just a little FYI...
The sorting code I posted may stumble if you have rooms with the same number, but have a letter at the end because I turn them into integers to sort, found out that it works better that way.  If you have letter/number combinations you might want to test it out how it is, and without the changing them to integers part.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #84 on: February 27, 2006, 05:21:42 PM »
Just a little FYI...
The sorting code I posted may stumble if you have rooms with the same number, but have a letter at the end because I turn them into integers to sort, found out that it works better that way.  If you have letter/number combinations you might want to test it out how it is, and without the changing them to integers part.

Tim

So far everything works great. It will always be numbers.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Make Sheet Index using obectDBX
« Reply #85 on: February 27, 2006, 05:25:00 PM »
Was playing while you guys were posting and wasn't going to post, but, ...

Tim, I'd expected No's to cause problems too , but seems not .. ..

by
Quote
It will always be numbers.
do you mean numbers or strings representing numbers ?
Code: [Select]
(setq dwgData (list "UTB30930"
                    (list (list "Entry" 01 "2-1-1-1   ")
                          (list "Utility" 05 "2-1-1-1   ")
                          (list "Kitchen" 04 "2-1-1-1   ")
                          (list "Bath" 08 "2-1(2)-1-1")
                          (list "Closet" 06 "1-1-1-1   ")
                          (list "Dining" 03 "1-1-1-1   ")
                          (list "Bedroom" 07 "1-1-1-1   ")
                          (list "Living" 02 "1-1-1-1   ")
                          (list "Balcony" 12 "3-5-4-1   ")
                          (list "Storage" 11 "3-6-4-3   ")
                          (list "Closet" 06 "1-1-1-1   ")
                          (list "Closet" 06 "1-1-1-1   ")
                          (list "Bath" 08 "2-1(2)-1-1")
                          (list "Bedroom" 07 "1-1-1-1   ")
                    )
              )
)
(setq header (car dwgData)
      Data   (cadr dwgData)
)

(setq NewData (vl-sort Data '(lambda (a b) (< (cadr a) (cadr b)))))


(setq NewDwgData (list header NewData))

Quote
("UTB30930" (("Entry"    1 "2-1-1-1   ")
             ("Living"    2 "1-1-1-1   ")
             ("Dining"    3 "1-1-1-1   ")
             ("Kitchen" 4 "2-1-1-1   ")
             ("Utility" 5 "2-1-1-1   ")
             ("Closet"    6 "1-1-1-1   ")
             ("Closet"    6 "1-1-1-1   ")
             ("Closet"    6 "1-1-1-1   ")
             ("Bedroom" 7 "1-1-1-1   ")
             ("Bedroom" 7 "1-1-1-1   ")
             ("Bath"    8 "2-1(2)-1-1")
             ("Bath"    8 "2-1(2)-1-1")
             ("Storage" 11 "3-6-4-3   ")
             ("Balcony" 12 "3-5-4-1   ")
            )
)


« Last Edit: February 27, 2006, 05:28:02 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Make Sheet Index using obectDBX
« Reply #86 on: February 27, 2006, 05:31:33 PM »
Sorry I should have said something sooner. I already had a sort going when Tim posted so I didn't look too hard at it.
If you look at the file you'll see it.
Code: [Select]
  (defun srt (data / e1 e2)
    (vl-sort data '(lambda (e1 e2) (< (cdar e1) (cdar e2))))
  )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Make Sheet Index using obectDBX
« Reply #87 on: February 27, 2006, 05:40:40 PM »
<snip>
by
Quote
It will always be numbers.
do you mean numbers or strings representing numbers ?
< snip >

BTW : String or numbers each work for the sort.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #88 on: February 27, 2006, 05:41:11 PM »

do you mean numbers or strings representing numbers ?
It would be strings representing numbers because they are gotten from attributed blocks.

Sorry I should have said something sooner. I already had a sort going when Tim posted so I didn't look too hard at it.
If you look at the file you'll see it.
Code: [Select]
  (defun srt (data / e1 e2)
    (vl-sort data '(lambda (e1 e2) (< (cdar e1) (cdar e2))))
  )

All good Alan.  I just wanted to state that incase someone looks later at it.
FYI...
You don't have to make the variables "e1" & "e2" local to the function because they are already local to the lambda function.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Make Sheet Index using obectDBX
« Reply #89 on: February 27, 2006, 05:50:28 PM »
Good point. Thanks
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.