Author Topic: Complaining about Loading the Dishwasher ??  (Read 14810 times)

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: Complaining about Loading the Dishwasher ??
« Reply #15 on: November 15, 2006, 05:56:51 AM »
I might have confused the issue by just using a standard old lisp defun - was meant to demonstrate concept only.
Equally applicable to DBX. ESPECIALLY, if there is ever only 1 insert....why iterate over EVERY entity when you can go straight to the one you want? <rhetorical question> :)

Cheers,

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Complaining about Loading the Dishwasher ??
« Reply #16 on: November 15, 2006, 06:20:31 AM »
I think you might misunderstand me Kerry. The basic premise behind what I posted is this:

1. Go STRAIGHT to the Block Table Record in question by using item on the block table - no need to loop over every entity in every layout.
...................
Cheers,
Glenn.


Ahhh OK, hadn't considered that.
The block MAY be any one of 5 used for each job, in various named combinations, and may include the project Number in it's name.   May require reading config files to determine the full border name.
I s'pose I could get a list of the Blocks in the Collection, Pattern match the name, and go from there. 

Interesting idea, thanks.

.. though at this point it would be difficult getting a return on any further investment, just the satisfaction of improving it, and as a by product, possibly saving a couple of minutes each month.

We are a peculiar breed, hey ?


 
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.

Glenn R

  • Guest
Re: Complaining about Loading the Dishwasher ??
« Reply #17 on: November 15, 2006, 06:36:38 AM »
I prefer to think of us as perfectionists/millisecondists (just invented a word I think) rather than peculiar per se :)

Cheers,
Glenn.

CADaver

  • Guest
Re: Complaining about Loading the Dishwasher ??
« Reply #18 on: November 15, 2006, 07:38:49 AM »
I prefer to think of us as perfectionists/millisecondists (just invented a word I think) rather than peculiar per se :)

Though peculiar none the less....

Chuck Gabriel

  • Guest
Re: Complaining about Loading the Dishwasher ??
« Reply #19 on: November 15, 2006, 08:08:06 AM »
Excellent trick Glenn.  Where did you learn that one?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Complaining about Loading the Dishwasher ??
« Reply #20 on: November 15, 2006, 01:02:12 PM »
Kerry, there's actually an even better way to do this......................................................C#   :evil:  :-D

I know, Already started ... :-)

 ... also easier to use SQL/ADO from C# than from VLisp.  ;-) 


I'm pleasantly surprised by how fast the VLisp is with DBX ...  better than 1000 drawings per minute is pretty slick including writing the data to file ...

If you want I can share mine, C#.  I'm sure it's not that pretty as it was my first one.  It opens the drawings database for edit, finds the title blocks, and updates the revisions on the title block.  Let me know.
Tim

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

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Complaining about Loading the Dishwasher ??
« Reply #21 on: November 15, 2006, 04:36:21 PM »
Post <share> away Tim ...

broadening the knowledgebase would be great. !
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: Complaining about Loading the Dishwasher ??
« Reply #22 on: November 15, 2006, 04:58:19 PM »
Post <share> away Tim ...

broadening the knowledgebase would be great. !

You asked for it  :wink:
Okay the code is too long to post in a reply, so I will attach it.  Hope that is okay.

Couldn't attach a 'cs' file, so I changed the extension to 'lsp' just change it back once dl'ed.
Tim

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

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Complaining about Loading the Dishwasher ??
« Reply #23 on: November 15, 2006, 05:06:12 PM »
Great Tim, Thanks
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: Complaining about Loading the Dishwasher ??
« Reply #24 on: November 15, 2006, 05:16:24 PM »
Great Tim, Thanks
You're welcome.  If my logic seems flawed, please point it out as I'm just learning.
Tim

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

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Complaining about Loading the Dishwasher ??
« Reply #25 on: November 15, 2006, 05:20:06 PM »
I'm working from home today, so I'll try to have a look during what would have been "travelling time" tonight ..
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: Complaining about Loading the Dishwasher ??
« Reply #26 on: November 15, 2006, 05:23:36 PM »
I'm working from home today, so I'll try to have a look during what would have been "travelling time" tonight ..
If you working from home, enjoy it (I'm jealous).  Don't worry about my stuff, have fun.
Tim

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

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Complaining about Loading the Dishwasher ??
« Reply #27 on: November 15, 2006, 07:07:37 PM »
Heh, Glenn .. Good stuff .. very insightful !

Grabs the data OK .. Just need to test the speed, including writing .. later ..
Quote
Command:
Command: TEST1116B
((   ("DWG_NO_C" . "A016-C36")
     ("FOR_CON" . "FOR CONSTRUCTION")
     ("REV_BOX" . "1")
     ("TITLE-1" . "ROM DUMP POCKET - DUMP HOPPER")
     ("TITLE-2" . "STRUCTURAL STEELWORK DETAILS")
     ("TITLE-3" . "WALL FRAME W3 & W6 - COMMON PLATE - ITEM DETAILS")
     ("DRAWN" . "RMK")
     ("DRAWN_DATE" . "APR 06")
 .............. etc

Code: [Select]
;;; DBXTest1116-01.LSP
;;; kwb 20061116
;;; Testing Glenn's theory ... get the inserted block instance from the BlockTable
;;; will only work as expected when there is ONE instance of the Block.
;;;-------------------------------------------------------------------
;;;
(DEFUN c:Test1116b ( / BorderName DocName IAxDbDocument DataList )
    (SETQ BorderName    "BORDER*"
          DocName       (DOS_GETFILED "Select file"
                                      "J:\\DWGS"
                                      "Drawing files (*.dwg)|*.dwg|All files (*.*)|*.*||"
                        )
          IAxDbDocument (kdub:DBX:GetInterface)
    )
    ;; -----------------
    ;;   
    (IF (VL-CATCH-ALL-ERROR-P
            (VL-CATCH-ALL-APPLY 'VLA-OPEN (LIST IAxDbDocument DocName))
        )
        (SETQ IAxDbDocument nil)
    )
    (IF IAxDbDocument
        (SETQ DataList
                 (kdub:BDX:ReadAttributes-03 BorderName IAxDbDocument)
        )
    )
    (VLAX-RELEASE-OBJECT IAxDbDocument)
    DataList
)
;;;-------------------------------------------------------------------
;;;
(DEFUN kdub:BDX:ReadAttributes-03 ( BorderBlockName   IAxDbDocument
                                   /                 dbx-borderObject
                                   edata             BorderReference
                                   AttLst
                                  )
    ;;
    ;; Find the Block in the Block Table   
    ;;
    (VLAX-FOR blockDefinition (VLA-GET-BLOCKS IAxDbDocument)
        (IF (WCMATCH (STRCASE (VLA-GET-NAME blockDefinition)) BorderBlockName)
            (SETQ dbx-borderObject blockDefinition)
        )
    )
    ;;
    ;; If the AcDbBlockTableRecord is there, Grab the Ename and run with it ....
    ;;
    (IF dbx-borderObject
        (PROGN (FOREACH edata (ENTGET (VLAX-VLA-OBJECT->ENAME dbx-borderObject))
                   (IF (= (CAR edata) 331)
                       (SETQ BorderReference (CDR edata))
                   )
               )
               ;;
               ;; Extract the Attributes ..
               ;;
               (IF BorderReference
                   (SETQ AttLst
                            (CONS (MAPCAR
                                      '(LAMBDA (Att)
                                           (CONS (VLA-GET-TAGSTRING Att)
                                                 (VLA-GET-TEXTSTRING Att)
                                           )
                                       )
                                      (VLAX-INVOKE
                                          (VLAX-ENAME->VLA-OBJECT BorderReference)
                                          'GetAttributes
                                      )
                                  )
                                  AttLst
                            )
                   )
               )
        )
    )
    AttLst
)
;;;-------------------------------------------------------------------
;;;
 
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Complaining about Loading the Dishwasher ??
« Reply #28 on: November 15, 2006, 07:48:17 PM »
Prior to Clean-up and optimisation ...
My Machine at home has essentially identical spec's  to my box at work, but I've run both tests here ...

... the joys of using a removable drive for development source .. :-)

The Test1115D is the last one posted Yesterday
The Test1116C is the included here.
Quote
Command:
Command: test1115d
 132 Files completed in 6.1910 seconds.
Command:
Command: TEST1116C
 132 Files completed in 7.2500 seconds.
Command:

The previous is marginally faster.
I'm guessing ... perhaps using the database itteration and scarpering when the block is found works because the Border is usually inserted early in the drawing process, so IT MAY be close to the start of the database ... that could be tested I s'pose ..
Code: [Select]
;;;-------------------------------------------------------------------
;;;
(DEFUN c:Test1116c
       (/ BorderName FileList Path start finish IAxDbDocument dbxDoc)
    (SETQ BorderName "BORDER*"
          FileList   (DOS_GETFILEM
                         "Select files"
                         "J:\\DWGS"
                         "Drawing files (*.dwg)|*.dwg|All files (*.*)|*.*||"
                     )
    )
    (SETQ Path     (CAR FileList)
          FileList (MAPCAR '(LAMBDA (x) (STRCAT Path x)) (CDR FileList))
    )
    (SETQ start (GETVAR "millisecs"))
    ;;
    (SETQ IAxDbDocument (kdub:DBX:GetInterface))
    ;; -----------------
    ;;
    (FOREACH docname FileList
        (SETQ dbxDoc IAxDbDocument)
        (IF (VL-CATCH-ALL-ERROR-P
                (VL-CATCH-ALL-APPLY 'VLA-OPEN (LIST dbxDoc docname))
            )
            (SETQ dbxDoc nil)
        )
        (IF dbxDoc
            (kdub:BDX:ReadandSaveAttributes-04 docname BorderName dbxDoc)
        )
    )
    (VLAX-RELEASE-OBJECT IAxDbDocument)
    ;; -----------------
    ;;
    (SETQ finish (GETVAR "millisecs"))
    (PROMPT (STRCAT "\n "
                    (ITOA (LENGTH FileList))
                    " Files completed in "
                    (RTOS (/ (- finish start) 1000.0) 2 4)
                    " seconds."
            )
    )
    (PRINC)
)


;;;-------------------------------------------------------------------
;;;
(DEFUN kdub:BDX:ReadandSaveAttributes-04 (dwgFileName BorderBlockName   IAxDbDocument
                                   /                 dbx-borderObject
                                   edata             BorderReference
                                   AttLst
                                  )
    ;;
    ;; Find the Block in the Block Table   
    ;;
    (VLAX-FOR blockDefinition (VLA-GET-BLOCKS IAxDbDocument)
        (IF (WCMATCH (STRCASE (VLA-GET-NAME blockDefinition)) BorderBlockName)
            (SETQ dbx-borderObject blockDefinition)
        )
    )
    ;;
    ;; If the AcDbBlockTableRecord is there, Grab the Ename and run with it ....
    ;;
    (IF dbx-borderObject
        (PROGN (FOREACH edata (ENTGET (VLAX-VLA-OBJECT->ENAME dbx-borderObject))
                   (IF (= (CAR edata) 331)
                       (SETQ BorderReference (CDR edata))
                   )
               )
               ;;
               ;; Extract the Attributes ..
               ;;
               (IF BorderReference
                   (SETQ AttLst
                            (CONS (MAPCAR
                                      '(LAMBDA (Att)
                                           (CONS (VLA-GET-TAGSTRING Att)
                                                 (VLA-GET-TEXTSTRING Att)
                                           )
                                       )
                                      (VLAX-INVOKE
                                          (VLAX-ENAME->VLA-OBJECT BorderReference)
                                          'GetAttributes
                                      )
                                  )
                                  AttLst
                            )
                   )
               )
        )
    )
    (OR AttLst (SETQ AttLst '(" ")))
    ;;
    ;;
    ;; Write data to file.
    (SETQ fdesc_id (OPEN (STRCAT dwgFileName ".txt") "W"))
    (WRITE-LINE (VL-PRINC-TO-STRING (CAR AttLst)) fdesc_id)
    (SETQ fdesc_id (CLOSE fdesc_id))
    ;;
    ;;
)
;;;-------------------------------------------------------------------
;;;
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.

Glenn R

  • Guest
Re: Complaining about Loading the Dishwasher ??
« Reply #29 on: November 15, 2006, 08:54:53 PM »
Interesting - just something to keep in mind for future endeavours.
I suspect my approach would get significantly faster the larger the drawing got and the more inserts of the same block...however that's just a suspicion.

Good stuff Kerry.

Cheers,
Glenn.