Author Topic: sometimes ComboBox cannot be filled, what's wrong with my codes?  (Read 250 times)

khann

  • Full Member
  • ***
  • Posts: 153
Hi,
I want to add Block names into the ComboBox
I coded like this...

But sometimes the ComboBox does not fill anythings...
and Cad shows like this error messages :

; error: Unknown exception occurred
; warning: unwind skipped on unknown exception


what should I do at this time?
Thanks, Khann.




***
(setq *All_Block_Names (F:Sub_Get_All_Block_Names))


(dcl-ComboBox-Clear TransfoA1/Form/cboRBListNew)

(dcl-ComboBox-AddList TransfoA1/Form/cboRBListNew *All_Block_Names)



***


(defun F:Sub_Get_All_Block_Names ( / *ALL_BLOCKS *ALL_BLOCK_NAMES *CURDOC *TMP_BNAME)

   (setq *All_Block_Names '())
   (setq *Curdoc (vla-get-activedocument (vlax-get-acad-object)))
   (setq *All_Blocks (vla-get-blocks *Curdoc))

   (vlax-for *Block_Item *All_Blocks

      (setq *Tmp_BName (vla-get-name *Block_Item))

      (if (wcmatch (substr *Tmp_BName 1 4) "00*-")
    (progn
       (setq *All_Block_Names (cons *Tmp_BName *All_Block_Names))
    )
      )
   )

   (setq *All_Block_Names (reverse *All_Block_Names))

   (setq *All_Block_Names (vl-sort *All_Block_Names '<))

   *All_Block_Names

)

Fred Tomke

  • OpenDCL Technician
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2045
  • [ Mr. Bad Guy ]
    • Kommunale Entwicklungsplanung auf digitaler Basis - digital landscape and urban design
Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
« Reply #1 on: August 20, 2018, 08:57:40 PM »
Hi, I cannot see an error in the small piece.
I recommend to add some princ-hints to get closer to the line that hits the error, because I'm afraid that you can't debug this when it only occurs sometimes.
Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

khann

  • Full Member
  • ***
  • Posts: 153
Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
« Reply #2 on: August 20, 2018, 09:46:10 PM »
Hi, Fred
Thank you for your reply.
I cannot find what's wrong with this.

Sometimes ComboBox filled, but sometimes not...  :'( :'(

where I need to put "princ-hits" ?
« Last Edit: August 20, 2018, 09:48:09 PM by khann »

Fred Tomke

  • OpenDCL Technician
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2045
  • [ Mr. Bad Guy ]
    • Kommunale Entwicklungsplanung auf digitaler Basis - digital landscape and urban design
Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
« Reply #3 on: August 20, 2018, 10:00:19 PM »
I meant lines like this

Code: [Select]
(princ "\r\n... read Blocks ...\r\n)
(setq *All_Block_Names (F:Sub_Get_All_Block_Names))
(princ "\r\n... clear combo ...\r\n)
(dcl-ComboBox-Clear TransfoA1/Form/cboRBListNew)
(princ "\r\n... fill combo ...\r\n)
(dcl-ComboBox-AddList TransfoA1/Form/cboRBListNew *All_Block_Names)

please note, that the blocks-collection also contains modelspace, paperspaces, xrefs, dimensions (beginning with *D).

Regards, Fred

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

khann

  • Full Member
  • ***
  • Posts: 153
Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
« Reply #4 on: August 20, 2018, 10:12:41 PM »
Ok, I see.
Thank you Fred  :)

khann

  • Full Member
  • ***
  • Posts: 153
Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
« Reply #5 on: August 22, 2018, 06:46:43 PM »
Hi, Fred.
I tested with (princ "\n Test ... " )
every single line...

I'm not sure
but
when I changed wcmatch to only substr
It seemed fixed the "unwind errors."



(wcmatch (substr *Tmp_BName 1 4) "00*-")
=>
(and (= (substr *Tmp_BName 1 2) "00") (= (substr *Tmp_BName 4 1) "-"))

 ::) ::)

Thank you, Fred  :)
« Last Edit: August 22, 2018, 06:54:30 PM by khann »

Fred Tomke

  • OpenDCL Technician
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2045
  • [ Mr. Bad Guy ]
    • Kommunale Entwicklungsplanung auf digitaler Basis - digital landscape and urban design
Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
« Reply #6 on: August 22, 2018, 09:32:45 PM »
That's frustrating. Do not see any reason, why wcmatch shouldn't work in this case. Good, that you worked around that.
Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

khann

  • Full Member
  • ***
  • Posts: 153
Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
« Reply #7 on: August 22, 2018, 10:36:37 PM »
mmm..
So am I.
Maybe, my Acad does not like the wcmatch func.  :-\ :-\

Fred Tomke

  • OpenDCL Technician
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2045
  • [ Mr. Bad Guy ]
    • Kommunale Entwicklungsplanung auf digitaler Basis - digital landscape and urban design
Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
« Reply #8 on: August 22, 2018, 11:27:55 PM »
Hm, maybe add a String.IsNullOrEmpty-check right before calling wcmatch.
Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

khann

  • Full Member
  • ***
  • Posts: 153
Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
« Reply #9 on: August 24, 2018, 02:00:11 AM »
Mmm... Ok, Fred.
I will try again your advices.
Thank you  :)