Initget not working

Initget not working

christian_paulsen98V29
Enthusiast Enthusiast
795 Views
7 Replies
Message 1 of 8

Initget not working

christian_paulsen98V29
Enthusiast
Enthusiast

When i copy and paste some code off the internet it works perfect, but then as soon as i start changing to my own keywords it stops working. Below is the code.

 

(defun c:RELEASESTATE ()
(
(initget "Preliminary Released")
(setq keyword (getkword ""))
(command "GATTE" "B" "DWGSTATE" "STATE" keyword "YES")
)
0 Likes
796 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

You need to fill the prompt (getword "prompt") in [../..] format

 

(defun c:RELEASESTATE ()

  (initget "Preliminary Released")
  (setq keyword (getkword "Specify keyword [Preliminary/Released]: ")) 
  (command "GATTE" "B" "DWGSTATE" "STATE" keyword "YES")

  )

The red ones must match...

0 Likes
Message 3 of 8

christian_paulsen98V29
Enthusiast
Enthusiast

Found out i had and extra opening parenthesis. 

 

Now my issue is that the GATTE command is not working. I did some research and found out it is an express tool and not a native autocad command.

 

When im in autocad i can type in GATTE and it works perfectly. But i cant figure out how to call it in a LISP function.

0 Likes
Message 4 of 8

ВeekeeCZ
Consultant
Consultant

Try this

(vl-load-com)
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "gatte b dwgstate state " keyword " yes "))

 

Message 5 of 8

christian_paulsen98V29
Enthusiast
Enthusiast

This works but im trying to figure out why it works. Is there not an easier way to input the command. I can literally type "Gatte" into the command line and it works just fine. There isnt a way to trick autocad into thinking im typing the string "gatte" into the command line?

 

0 Likes
Message 6 of 8

christian_paulsen98V29
Enthusiast
Enthusiast

Also had to put /n after the new attribute data so that it would move onto the next argument. Here is the finished product.

 

(defun c:RELEASESTATE ()
	(vl-load-com)
	(initget "PRELIMINARY RELEASED")
	(if (setq keyword (getkword "[Preliminary/Released]: <Released>"))
		(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "gatte b dwgstate state " keyword "\nyes "))
		(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "gatte b dwgstate state RELEASED\nyes "))
	)
)
Message 7 of 8

john.uhden
Mentor
Mentor

@christian_paulsen98V29 ,

Am I mistaken, or does your initget keywords, being all capitalized, require the user to type in the entire word?  As opposed to ...

(initget "Preliminary Released")

which requires simply a "P" or an "R" (case not sensitive). 

John F. Uhden

Message 8 of 8

christian_paulsen98V29
Enthusiast
Enthusiast

Nope. Ive tried it every way possible and it seems to work. Clicking preliminary, clicking release, typing P, typing R, using the arrow keys to select an option then pressing enter, just pressing enter without selecting anything. Every way seems to work just fine.

0 Likes