Author Topic: inserting block reopens DCL form  (Read 141 times)

0 Members and 1 Guest are viewing this topic.

jhadams82

  • Mosquito
  • Posts: 11
inserting block reopens DCL form
« on: May 12, 2017, 12:15:52 pm »
Hi all!  First time poster here.  Sorry if this has been answered before, I tried to search but didn't find anything.

I only recently started using Autocad this past January, but I have a programming background so I quickly discovered LISP and eventually OpenDCL.  I'm trying to make a large program that automates part of my job and this is just one piece of the puzzle.  What I want to do is have a form that gets user input about the project and fills in some MTexts with that info.  That part works pretty well so far (tho once you guys get a look at my code, I bet there's a better way to do it :tongue2: ), but the next part is messing up the routine.

Once the user has filled in the form and hit submit, I populate some variables, close the form, then update the Mtext contents with the variables.  Here's where it gets weird.  Then I call the "insert" command and instead of inserting the block, it reopens the form and asks for the block name!  If I remove this line and put it in it's own c:function and have the user call it separately, it works fine.  So weird.  Having a separate function works for now, but eventually I want this thing to run all on it's own without stopping.  Anybody have a clue what's going on or a possible way around?  TIA

Code - Auto/Visual Lisp: [Select]
  1. (defun c:border_text/Form1/btn_submit#OnClicked (/)
  2.  (setq jobNum (dcl-Control-GetText border_text/Form1/tb_jobNum))
  3.  (setq projectName (dcl-Control-GetText border_text/Form1/tb_projectName))
  4.  (setq planType (dcl-Control-GetText border_text/Form1/tb_planType))
  5.  (setq address (dcl-Control-GetText border_text/Form1/tb_address))
  6.  (setq cityCountyState (dcl-Control-GetText border_text/Form1/tb_cityCountyState))
  7.  (setq mapNum (dcl-Control-GetText border_text/Form1/tb_mapNum))
  8.  (setq parcel (dcl-Control-GetText border_text/Form1/tb_parcel))
  9.  
  10.  (dcl-Form-Close border_text/Form1)
  11.  
  12.  
  13.  
  14.  (setq ob_planType (vlax-ename->vla-object (ssname (ssget '(34.2304 11.0993)) 0)))
  15.  (vlax-put-property ob_planType "TEXTSTRING" planType)
  16.  
  17.  (setq ob_projName (vlax-ename->vla-object (ssname (ssget '(34.6853 10.5258)) 0)))
  18.  (vlax-put-property ob_projName "TEXTSTRING" projectName)
  19.  
  20.  (setq ob_address (vlax-ename->vla-object (ssname (ssget '(35.0368 11.5858)) 0)))
  21.  (vlax-put-property ob_address "TEXTSTRING" address)
  22.  
  23.  (setq ob_cityCountyState (vlax-ename->vla-object (ssname (ssget '(35.1842 10.7275)) 0)))
  24.  (vlax-put-property ob_cityCountyState "TEXTSTRING" cityCountyState)
  25.  
  26.  (setq ob_jobNum (vlax-ename->vla-object (ssname (ssget '(34.5032 0.6551)) 0)))
  27.  (vlax-put-property ob_jobNum "TEXTSTRING" jobNum)
  28.  
  29.  (command "-insert" "P:/CSDG Standards/AutoCAD STD/CSDG Blocks/Stamps/Jim Stamp.dwg" '(34.4163 17.5196) "" "" "")
  30. )

roy_043

  • Swamp Rat
  • Posts: 1439
  • BricsCAD 16
Re: inserting block reopens DCL form
« Reply #1 on: May 12, 2017, 12:51:12 pm »
You cannot use command calls in event handlers:
http://www.opendcl.com/forum/index.php?topic=2495.0

You should consider using attributes (attached to the 'stamp' block) instead of mtext entities. They are the more logical choice for this type of data.


jhadams82

  • Mosquito
  • Posts: 11
Re: inserting block reopens DCL form
« Reply #2 on: May 12, 2017, 01:12:32 pm »
well, that explains it!  Yep, sure enough.  I moved the "insert" command outside the event handler and it all works great.  Thanks!