OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: khann on August 20, 2018, 08:49:17 PM

Title: sometimes ComboBox cannot be filled, what's wrong with my codes?
Post by: khann on August 20, 2018, 08:49:17 PM
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

)
Title: Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
Post by: Fred Tomke 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
Title: Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
Post by: khann 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" ?
Title: Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
Post by: Fred Tomke 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
Title: Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
Post by: khann on August 20, 2018, 10:12:41 PM
Ok, I see.
Thank you Fred  :)
Title: Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
Post by: khann 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  :)
Title: Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
Post by: Fred Tomke 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
Title: Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
Post by: khann on August 22, 2018, 10:36:37 PM
mmm..
So am I.
Maybe, my Acad does not like the wcmatch func.  :-\ :-\
Title: Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
Post by: Fred Tomke on August 22, 2018, 11:27:55 PM
Hm, maybe add a String.IsNullOrEmpty-check right before calling wcmatch.
Regards, Fred
Title: Re: sometimes ComboBox cannot be filled, what's wrong with my codes?
Post by: khann on August 24, 2018, 02:00:11 AM
Mmm... Ok, Fred.
I will try again your advices.
Thank you  :)