TheSwamp
Code Red => Visual DCL Programming => AutoLISP (Vanilla / Visual) => OpenDCL => Topic started by: jhadams82 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
(defun c:border_text
/Form1
/btn_submit#OnClicked
(/) (setq jobNum
(dcl
-Control
-GetText border_text
/Form1
/tb_jobNum
)) (setq projectName
(dcl
-Control
-GetText border_text
/Form1
/tb_projectName
)) (setq planType
(dcl
-Control
-GetText border_text
/Form1
/tb_planType
)) (setq address
(dcl
-Control
-GetText border_text
/Form1
/tb_address
)) (setq cityCountyState
(dcl
-Control
-GetText border_text
/Form1
/tb_cityCountyState
)) (setq mapNum
(dcl
-Control
-GetText border_text
/Form1
/tb_mapNum
)) (setq parcel
(dcl
-Control
-GetText border_text
/Form1
/tb_parcel
))
(dcl
-Form
-Close border_text
/Form1
)
(command "-insert" "P:/CSDG Standards/AutoCAD STD/CSDG Blocks/Stamps/Jim Stamp.dwg" '
(34.4163 17.5196) "" "" "") )
-
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.
-
well, that explains it! Yep, sure enough. I moved the "insert" command outside the event handler and it all works great. Thanks!