Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Member
rscamp13
Posts: 4
Registered: ‎12-01-2010
Message 1 of 8 (494 Views)
Accepted Solution

DCL lisp Routine

494 Views, 7 Replies
12-01-2010 11:41 AM

Can anyone help?  I have the following:

 

(defun RSplot (Title$ Question$ / Answer$ Dcl_Id% Return#)
  (princ "\nRSPlot")(princ)
  (vl-load-com)
  (setq Dcl_Id% (load_dialog "RSPlot.dcl"))
  (new_dialog "RSPlot" Dcl_Id%)
  (set_tile "Title" Title$)
  (set_tile "Text1" Question$)
  (action_tile "Freeze" "(done_dialog)(command ".layer" "_freeze" (strcat "KS-JK-Sig")"))
  (action_tile "Thaw" "(done_dialog 0)(command ".layer" "_thaw" (strcat "KS-JK-Sig")"))
  (setq Return# (start_dialog))
  (unload_dialog Dcl_Id%)
  (if (= Return# 1)
    (setq Answer$ "Freeze")
    (setq Answer$ "Thaw")
  )
  Answer$
);defun RSPlot
(princ)

 

Now for the DCL file:

 

RSPlot : dialog {
  key = "Title";
  label = "";//Title$ from lsp file
  spacer;
  : text {
    key = "Text1";
    label = "";//Question$ from lsp file
    width = 35.0;
    alignment = centered;
  }
  spacer;
  : row {
    fixed_width = true;
    alignment = centered;
    : button {
      key = "Freeze";
      label = "&Freeze";
      width = 7.92;
      fixed_width = true;
    }
    : button {
      key = "Thaw";
      label = "&Thaw";
      is_default = true;
      width = 7.92;
      fixed_width = true;
    }
  }
}//RSPlot

 

I get the miplaced dot on input message.  Any suggestions?

 

Thanks,

 

Rich Scampoli

Questiion for you,

why  (strcat "KS-JK-Sig")

 

Not sure if this is want you want to achieve , i would have done it this way.

 

(defun RSplot (Title$ Question$ / Answer$ Dcl_Id% Return#)
(princ "\nRSPlot")(princ)
(vl-load-com)
(setq Dcl_Id% (load_dialog "RSPlot.dcl"))
(new_dialog "RSPlot" Dcl_Id%)
(set_tile "Title" Title$)
(set_tile "Text1" Question$)
(action_tile "Freeze" "(done_dialog 1)(setq Answer$ \"Frozen\")")
(action_tile "Thaw" "(done_dialog 1)(setq Answer$ \"Thawed\")")
(start_dialog)
(unload_dialog Dcl_Id%)
(if (= Answer$ "Frozen")
(command ".layer" "_freeze" "KS-JK-Sig" "")
(command ".layer" "_thaw" "KS-JK-Sig" ""))
(princ (strcat "\nLayer KS-JK-Sig" Answer$))(princ)
)

 Hope this helps

 

 

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 2 of 8 (474 Views)

Re: DCL lisp Routine

12-01-2010 08:33 PM in reply to: rscamp13

Questiion for you,

why  (strcat "KS-JK-Sig")

 

Not sure if this is want you want to achieve , i would have done it this way.

 

(defun RSplot (Title$ Question$ / Answer$ Dcl_Id% Return#)
  (princ "\nRSPlot")(princ)
  (vl-load-com)
  (setq Dcl_Id% (load_dialog "RSPlot.dcl"))
  (new_dialog "RSPlot" Dcl_Id%)
  (set_tile "Title" Title$)
  (set_tile "Text1" Question$)
  (action_tile "Freeze" "(done_dialog 1)(setq  Answer$ \"Frozen\")")
  (action_tile "Thaw" "(done_dialog 1)(setq Answer$ \"Thawed\")")
  (start_dialog)
  (unload_dialog Dcl_Id%)
  (if (= Answer$ "Frozen")
     (command ".layer" "_freeze" "KS-JK-Sig" "")
  	(command ".layer" "_thaw" "KS-JK-Sig" ""))
   
    (princ (strcat "\nLayer KS-JK-Sig"  Answer$))(princ)
)

 Hope this helps

 

 

Distinguished Mentor
scottbolton
Posts: 647
Registered: ‎08-30-2005
Message 3 of 8 (452 Views)

Re: DCL lisp Routine

12-02-2010 02:00 AM in reply to: rscamp13

If you use the VLIDE to write your code you'd see the error straight away. Also, when you load the code and get the ";error: misplaced dot on input" message, if you double-click that message it will take you to the error in the code. Very nifty.

 

Anyroad, you're trying to put quotes inside quotes which you cannae do. You'll need something like:

 

(action_tile "Freeze" "(done_dialog)(command \".layer\" \"_freeze\" (strcat \"KS-JK-Sig\")")

 

S

Member
rscamp13
Posts: 4
Registered: ‎12-01-2010
Message 4 of 8 (442 Views)

Re: DCL lisp Routine

12-02-2010 06:05 AM in reply to: pbejse

pbejse,

 

Thank you so much.  That worked perfectly.  I am very new to lisp writing lisp.  I have to do more research on Visual lisp to help me, etc. but this gives me a great launching pad.  I cannot thank you enough.

 

Rich Scampoli

Member
rscamp13
Posts: 4
Registered: ‎12-01-2010
Message 5 of 8 (441 Views)

Re: DCL lisp Routine

12-02-2010 06:10 AM in reply to: scottbolton

Scott,

 

Thank you.   That is great to know.  As I said, I am very new to lisp so I hadn't realized my mistakes.

 

Rich Scampoli

 

 

 

 

Distinguished Contributor
andrew.nao
Posts: 216
Registered: ‎09-25-2008
Message 6 of 8 (438 Views)

Re: DCL lisp Routine

12-02-2010 06:15 AM in reply to: rscamp13

look into using open dcl much easier

Member
rscamp13
Posts: 4
Registered: ‎12-01-2010
Message 7 of 8 (433 Views)

Re: DCL lisp Routine

12-02-2010 06:30 AM in reply to: pbejse

Now another question, if I may.  I cannot seem to get this to work with my reactor:

 

(setq plot_rctr
(vlr-command-reactor nil '((:vlr-commandWillStart . StartPlot))))

(defun StartPlot (calling-reactor endcommandInfo / thecommandstart)

   (setq thecommandStart (nth 0 endcommandInfo))

    (if (= thecommandStart "PLOT")(RSPlot "Layer: KS-JK-Sig" "What would you like to do?")
    )
  )

 

Any ideas?

 

 

Distinguished Contributor
andrew.nao
Posts: 216
Registered: ‎09-25-2008
Message 8 of 8 (413 Views)

Re: DCL lisp Routine

12-02-2010 12:59 PM in reply to: rscamp13

im not that up on the reactors and since no where is the variable plot_rctr used in your code you posted

i would say

 

change this line

(setq plot_rctr
(vlr-command-reactor nil '((:vlr-commandWillStart . StartPlot))))

 

to

(vlr-command-reactor nil '((:vlr-commandWillStart . StartPlot)))

 

here is my reactor for saving on close maybe it will help ya

 

[code]

(setq App      (vlax-Get-Acad-Object)
      Doc      (vla-Get-ActiveDocument App)
      DwgProps (vla-Get-SummaryInfo Doc)
)

(setq Num (vla-NumCustomInfo DwgProps)) ;gets number of custom fields

 

(defun DoBeforeSave(/)
(vlr-command-reactor nil '((:vlr-commandWillStart . DoMyStuff)))
(princ)
)
(defun DoMyStuff (reactor params)
(if (= (strcase (car params)) "SAVEAS")
(progn

;;==============do stuff here
(if (> num 0)
(progn
         (vla-put-keywords dwgprops "")
         (vla-put-subject dwgprops "")
         (vla-put-Title dwgprops "")
         (vla-put-comments dwgprops "")
         (vla-put-author dwgprops "")


            (repeat num
                (vla-GetCustomByIndex DwgProps 0 'id 'value)

                   (if (vl-catch-all-apply
                'vla-removecustombykey
               (list dwgprops id)
                      )
                     (vla-addcustominfo dwgprops id "")

                   ) ;if
            ) ;repeat
 )
)
;;================

)
)
)

 

[/code]

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.