sometimes ComboBox cannot be filled, what's wrong with my codes?

Started by khann, August 20, 2018, 08:49:17 PM

Previous topic - Next topic

khann

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

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

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" ?

Fred Tomke

I meant lines like this


(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

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  :)

Fred Tomke

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

mmm..
So am I.
Maybe, my Acad does not like the wcmatch func.  :-\ :-\

Fred Tomke

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

Mmm... Ok, Fred.
I will try again your advices.
Thank you  :)