Author Topic: Code too slow  (Read 6014 times)

0 Members and 1 Guest are viewing this topic.

ymg

  • Guest
Re: Code too slow
« Reply #15 on: May 01, 2015, 06:09:43 AM »
Lupo,

Maybe it could be faster if instead of creating Selection Set,
you creates List of "Entity Names".

ymg

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Code too slow
« Reply #16 on: May 01, 2015, 06:46:14 AM »
@ Lupo76:
Maybe using (vla-getxrecorddata) is faster than using (entget)?
But to get an 'instantaneous' selection set you should try ronjonp's advice in post #5: Create additional registered apps.

Note:
In BricsCAD you will not have this issue because you can create an ssget filter using values inside Xdata.
This works in BicsCAD:
Code: [Select]
(ssget "_X" '((-3 ("NOMEMYAPP" (1000 . "TIPOOGG=MARCATURA")))))
(ssget "_X" '((-3 ("NOMEMYAPP" (1000 . "IDFERRO=DEFAULT_*")))))

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Code too slow
« Reply #17 on: May 01, 2015, 09:05:35 AM »
...
1. Rewrite the application to use a new structure of xdata, allowing higher speed when creating selection sets
2. After starting the application, if a user opens a DWG file that contains the old structure of xdata, starts a function that converts it like new.
...
http://www.theswamp.org/index.php?action=post;quote=544774;topic=49383.0;last_msg=544845

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
Re: Code too slow
« Reply #18 on: May 01, 2015, 10:27:23 AM »
Lupo,

Maybe it could be faster if instead of creating Selection Set,
you creates List of "Entity Names".

ymg
CAB code do that:
 >>> (setq result (cons ent result))

Lupo76

  • Bull Frog
  • Posts: 343
Re: Code too slow
« Reply #19 on: May 01, 2015, 11:27:08 AM »
I did some more extensive tests.
Unfortunately I discovered that the slowness is not determined only by the group of selection, but also from the code that handles it later.
With your advice I managed to speed up the creation of group selection.
I also tried the way of the List of "Entity Names".

But now I have to check out the rest of the code.
There is a strange thing though ... to test the speed of the code I inserted between rows, some (princ "\nX"), where "X" is a sequential number.
At a certain point in the code I have inserted the following two lines, one after the other
(princ "\n5")
(princ "\n6")

The number 5 appears immediately, while the number 6 has a delay of about 1 ".
This is very strange if I consider that between (princ "\n5") and (princ "\n6"), there is no code!  :-o

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Code too slow
« Reply #20 on: May 01, 2015, 11:32:01 AM »
What CAD program are you using?
Quote
Non Autodesk DWG.  This DWG file was saved by a software application that was not developed or licensed by Autodesk.  Autodesk cannot guarantee the application compatibility or integrity of this file.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lupo76

  • Bull Frog
  • Posts: 343
Re: Code too slow
« Reply #21 on: May 01, 2015, 11:34:25 AM »
What CAD program are you using?
Quote
Non Autodesk DWG.  This DWG file was saved by a software application that was not developed or licensed by Autodesk.  Autodesk cannot guarantee the application compatibility or integrity of this file.

BricsCAD V15, however, the application must also be compatible with AutoCAD

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
Re: Code too slow
« Reply #22 on: May 01, 2015, 01:00:02 PM »
Lupo,
I advise you to review the structure of the xdata, in particular the meaning of a value should not be the contents of a string but the position or sequence of the pair in the structure
 
Code: [Select]
  (-3
      (
         "EMILISPCA"
         (1000 . "TIPOOGG=FERRO")
         (1000 . "IDFERRO=DEFAULT_1")
         (1000 . "TIPOFERRO=ESPLOSO")
         (1011 118.650976974287 -84.5345340970474 0.0)
         (1011 128.650976974287 -84.5345340970474 0.0)
         (1011 118.650976974287 -74.5345340970474 0.0)
         (1040 . 1.0)
      )
   )
Code: [Select]
  (-3
      (
         "EMILISPCA"
         (1000 . "FERRO")
         (1000 . "DEFAULT_1")
         (1000 . "ESPLOSO")
         (1011 118.650976974287 -84.5345340970474 0.0)
         (1011 128.650976974287 -84.5345340970474 0.0)
         (1011 118.650976974287 -74.5345340970474 0.0)
         (1040 . 1.0)
      )
   )
[code]
So:
1° assoc 1000 > TIPOOGG
2° assoc 1000 > IDFERRO
3° assoc 1000 > TIPOFERRO

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Code too slow
« Reply #23 on: May 01, 2015, 02:35:31 PM »
Regarding the formatting of the xdata I would go a bit further than Marc'Antonio's suggestion:
http://www.theswamp.org/index.php?topic=48868.msg540029#msg540029

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
Re: Code too slow
« Reply #24 on: May 02, 2015, 04:14:56 AM »
Regarding the formatting of the xdata I would go a bit further than Marc'Antonio's suggestion:
http://www.theswamp.org/index.php?topic=48868.msg540029#msg540029
Many years ago I had a program  (2d reinforced concrete beams, now abandoned) similar to Lupo's, this is an example of storing information with xdata
Code: [Select]

  (-3
      (
         "2DBEAM_PIL"
         (1002 . "{")
         (1002 . "{")
         (1005 . "418")
         (1070 . 3)
         (1040 . 5.0)
         (1011 252.703096126625 194.012274842227 0.0)
         (1040 . 80.0)
         (1040 . 60.0)
         (1040 . 55.0)
         (1000 . "B")
         (1002 . "}")
         (1002 . "{")
         (1040 . 270.0)
         (1040 . 270.0)
         (1040 . 300.0)
         (1002 . "}")
         (1002 . "{")
         (1040 . 40.0)
         (1040 . 25.0)
         (1040 . 25.0)
         (1040 . 25.0)
         (1002 . "}")
         (1002 . "{")
         (1040 . 15.0)
         (1040 . 10.0)
         (1040 . 15.0)
         (1040 . 15.0)
         (1002 . "}")
         (1002 . "}")
      )
   )
)
  (-3
      (
         "2DBEAM_FER"
         (1002 . "{")
         (1005 . "425")
         (1005 . "418")
         (1000 . "LTot")
         (1000 . "P00FerPil")
         (1002 . "}")
      )
   )




Jeff H

  • Needs a day job
  • Posts: 6150
Re: Code too slow
« Reply #25 on: May 02, 2015, 05:27:59 PM »