Jump to content

DCL Move Error


jonathann3891

Recommended Posts

Why does the move command get rejected when called from a DCL?

 

For learning purposes I'm attempting to create a DCL that will allow me to pick steel members (Advance Steel) and move them along the specified axis.

image.png.03baaee506ac0a815d0d9495354e8e2f.png

 

When the "OK" button is pressed it rejects a simple move command

;; OK Button
(defun c:WPO/Form1/Ok#OnClicked (/)
  (setq XVAL (dcl-Control-GetText WPO/Form1/XVAL)
	YVAL (dcl-Control-GetText WPO/Form1/YVAL)
	ZVAL (dcl-Control-GetText WPO/Form1/ZVAL)
	SS (setq SS (ssget "_:L"))
	);setq
  (command "_.move" ss ""  "_non" '(0. 0. 0.))
  )

 

I found and modified the lisp below to do the same thing without a dialog box.

 

I'd like to get this working by inputting values in the input boxes and any input box that is left blank will be ignored.

(defun c:fff (/ ss)
  (if (and (setq ss (ssget "_:L"))
           (or *cm-fl*
               (setq *cm-fl* "X"))
           (not (initget "X Y Z"))
           (setq *cm-fl* (cond ((getkword (strcat "\nFilter [X/Y/Z] <" *cm-fl* ">: ")))
                               (*cm-fl*)))
           )
    (progn
      (command "_.move" ss ""  "_non" '(0. 0. 0.))
      (while (> (getvar 'CMDACTIVE) 0)
        (command (cdr (assoc *cm-fl* '(("X" . ".YZ") ("Y" . ".XZ") ("Z" . ".XY")))) "_non" '(0. 0. 0.) pause))))
  (princ)
  )

 

Any help would be much appreciated.

WPO.LSP WPO.odcl

Edited by jonathann3891
Link to comment
Share on other sites

First off tell ChatGPT I said whats up. The simple move command has only 1 point needs two

 

Quote

any input box that is left blank will be ignored.

 

Can't do that it needs to be set to 0 if blank or the move command will error. Can't have a point (12. nil 3.) using the (or it will first look to set the value from the dcl if its nil then it will set it to 0. Might have to change it to "0"

 

;; OK Button
(defun C:WPO/Form1/Ok#OnClicked (/ XVAL YVAL ZVAL SS)
  (or (setq XVAL (dcl-Control-GetText WPO/Form1/XVAL)) (setq XVAL 0))
  (or (setq YVAL (dcl-Control-GetText WPO/Form1/YVAL)) (setq YVAL 0))
  (or (setq ZVAL (dcl-Control-GetText WPO/Form1/ZVAL)) (setq ZVAL 0))
  (setq SS (setq SS (ssget "_:L")))
  (command "_.move" ss "" "_non" '(0. 0. 0.) "_non" (list XVAL YVAL ZVAL))
)

 

Also if you want this to run off the dcl only you should remove the "C:" infront of all the commands this makes it a type able command. meaning you could run it with out the dcl inputs.

Link to comment
Share on other sites

Quote

Also if you want this to run off the dcl only you should remove the "C:" infront of all the commands this makes it a type able command. meaning you could run it with out the dcl inputs.

 

This is how opendcl works.

Link to comment
Share on other sites

If you look at my multi getvals.lsp it is a library program using normal DCl and no need for a custom dcl needs only 2 code lines to make the dcl. You make the list to suit from 1 to about 20 values can be entered, default values can be set or values remembered when ran again.

Multi GETVALS.lsp

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values " "X change " 5 4 "0" "Y change " 5 4 "0" "Z change" 5 4 "0")))
(setq xyz (list (atof (nth 0 ans))(atof (nth 1 ans))(atof (nth 2 ans))))

(command "_.move" ss "" "_non" '(0. 0. 0.) "_non" xyz)

 

image.png.034e9fc645d6382432250c1b07658a72.png

 

I stayed away from Opendcl even though its a great program, if doing external work its one more program a client must load and at times that can be a nightmare.

  • Like 2
Link to comment
Share on other sites

Thank you @BIGAL! That is a lot simpler than I was thinking it was going to be.

 

@mhupp I did not use ChatGPT. I used OpenDCL's content browser and events to create the dialog functions. 

Link to comment
Share on other sites

Sorry wasn't trying to make fun. usually when ppl use chatgpt their variable names and functions get extremely long/specific. guess that is the same for opendcl.

 

That uses the VBA user forums but then encrypts the dcl file? (not very open)

2nd what BIGAL said alwasy try to encoperate the dcl file into my lisp so it makes a temp dcl file. one less thing to keep track of/get lost.

  • Like 1
Link to comment
Share on other sites

Yup, reading through this, your project is what BigAls Multi GetVALS was born for.

Might need a slight check in case the user inputs anything apart from numbers and perhaps also a check in case they delete the value to leave a blank field.

 

 

Kind of agree with MHUPP - seeing this more often on here that users are asking for help after asking an automated process to create something - you can spot it and they don't always create the best code, humans are still ahead of the game here. Likewise agree that making the DCL on the fly, as needed is a lot simpler especially if others are going to use it, remind me one day to post my template that creates it all, just need to fill in the DCL details

Link to comment
Share on other sites

BIGAL's routine worked as it should, but I'd like to learn what the problem with the opendcl program I'm working on.

 

Everything seems to be working but the move command. I keep getting: Error: AutoCAD command rejected: "_.move"

 

I've set the default values to zero and created a list a little different than mhupp's example

(defun c:WPO/Form1#OnInitialize (/)
  (if (not XVAL)(setq XVAL "0"))
  (if (not YVAL)(setq YVAL "0"))
  (if (not ZVAL)(setq ZVAL "0"))
  (dcl-Control-SetText WPO/Form1/XVAL XVAL)
  (dcl-Control-SetText WPO/Form1/YVAL YVAL)
  (dcl-Control-SetText WPO/Form1/ZVAL ZVAL)
)

;; OK Button
(defun c:WPO/Form1/Ok#OnClicked (/)
  (setq XVAL (dcl-Control-GetText WPO/Form1/XVAL)
	YVAL (dcl-Control-GetText WPO/Form1/YVAL)
	ZVAL (dcl-Control-GetText WPO/Form1/ZVAL)
	 XYZ (list (atof XVAL)(atof YVAL)(atof ZVAL))
	SS (setq SS (ssget "_:L"))
	);setq
  (command "_.move" SS "" "_non" '(0. 0. 0.) "_non" XYZ)
  )

 

Link to comment
Share on other sites

Just a comment the vl-filename-mktemp makes a temporary file in the directory set in your Options, Files, Temp path. If you crash a lisp it will sometimes leave behind the ~00034.dcl file. You may also be horrified how much other stuff ends up there DWL, AC$, SV$ files. I have set my temp path to a top level directory d:\Acadtemp and have a bat file that I run every now and then that cleans up the directory. So check you temporary directory.

 

Regards

Link to comment
Share on other sites

I'll usually specify a file name in the temporary folder that way if it all crashes I am not leaving behind loads of temporary files - just the one for each DCL, or other temp. files

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...