Set specefics values to the prompt and run other rotine using that values

Set specefics values to the prompt and run other rotine using that values

gustavobernardi
Advocate Advocate
1,014 Views
10 Replies
Message 1 of 11

Set specefics values to the prompt and run other rotine using that values

gustavobernardi
Advocate
Advocate

Hi Guys, can I specify the required values of a lisp and run it like a AutoCAD command (without coping the code or modifying the original)?

 

Example:

 

When I use commands, I can specify previosly and run in silent mode:

(command "._-Layer" "M" "Walls" "C" "6" "" "")

 

 

If I try it on a lisp, it doesn't work:

 

(defun c:POA()
((C:PORTA2D )"A") )

 

 

In this case, I have a lisp wich inserts Door blocks and when I use the command, the "A" option insert a Single flush door.

 

TIA

0 Likes
1,015 Views
10 Replies
Replies (10)
Message 2 of 11

john.uhden
Mentor
Mentor

If the c:POTRTA2D function takes one argument, then try...

 

(defun c:POA()
  (C:PORTA2D "A")
)

However I don't think I have ever seen one build a c: function that takes an argument.  Not that you can't do it, but just that it's kind of abnornal.

Perhaps you should build a PORTA2D function that takes an argument and then...

 

(defun c:POA()
(PORTA2D "A") )

John F. Uhden

0 Likes
Message 3 of 11

ВeekeeCZ
Consultant
Consultant

If possible, use a macro (eg. button), that's the simplest way.

 

Otherwise see THIS thread.

0 Likes
Message 4 of 11

gustavobernardi
Advocate
Advocate

Thank you guys. I think I'll solve it differently. I was just curious to see if it was possible.

0 Likes
Message 5 of 11

scot-65
Advisor
Advisor
(defun c:POA() ((C:PORTA2D )"A") )

(defun c:POA ()
(c:PORTA2D)
(command "A")
)

untested
???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 6 of 11

gustavobernardi
Advocate
Advocate

Don't worked 😞

 

I think if it's possible to do I also can use for translating a lisp between languages.

 

Example: (command "._-layer" "m" "Wall" "c" 6 "") this function don't work on other languages. I know the command "._-layer" is universal, but the suboptions haven't the same key.

 

 

0 Likes
Message 7 of 11

Kent1Cooper
Consultant
Consultant

@gustavobernardi wrote:

.... 

Example: (command "._-layer" "m" "Wall" "c" 6 "") this function don't work on other languages. I know the command "._-layer" is universal, but the suboptions haven't the same key. 


Yes, they have -- it's the underscore character.  Try:

 

(command "._-layer" "_m" "Wall" "_c" 6 "" ""); [and finish the Layer command, as in Post 1]

 

Just don't also use the period/decimal character with options -- that's only for command names, to force use of the native command in case there might be a customized definition.

 

Also, you don't need the hyphen before the Layer command name.  That's to suppress the dialog box when used at the Command: line, but inside an AutoLisp (command) function, the non-dialog-box version is always used without  the need for the hyphen.

 

Kent Cooper, AIA
0 Likes
Message 8 of 11

gustavobernardi
Advocate
Advocate

Oh My gosh I think I've tried it any time... Works 🙂

 

But in the other situation. 

 

Example:

 

In portuguese I have a door command which structure simplified is like this:

 

 

(defun c:PORTA2D()
	(setq op(getkword "\nBloco de porta [Abrir 1 folha / aBrir 2 folhas ]<Abrir 1 folha>"))
		(cond
			((= op nil)(setq portalast (insertdoorA))
			((= op "A")(setq portalast (insertdoorA))
			((= op "B")(setq portalast (insertdoorB))
		)
)

 

 

My imagination is In english make something like this:

 

 

(defun c:DOOR2D()
	(setq op(getkword "\nDoor model [Door 1 panel / dooR 2 panel ]<Door 1 panel"))
		(cond
			((= op nil)(c:porta2D "A"))
			((= op "D")(c:porta2D "A"))
			((= op "R")(c:porta2D "B"))
		)
)

 

 

 

 

 

0 Likes
Message 9 of 11

john.uhden
Mentor
Mentor

Sorry, but your imagination is a little faulty.

 

Your c:PORTA2D function is not built to take an argument.

 

But the c:PORTA2D function looks fine to use as is.

John F. Uhden

0 Likes
Message 10 of 11

gustavobernardi
Advocate
Advocate

Yes, the function works fine.

 

But If I make a Portuguese, an English and a Spanish version it's necessary to recreate basically all the code again.

if have a change in the main code, it's necessary to correct all the instances.

 

But OK, I will create "engine subroutines" (to do  the job) and "interface subroutines" (for each language). I just wanted to not have to rebuild everything.

 

Thanks.

0 Likes
Message 11 of 11

john.uhden
Mentor
Mentor

There ya go... engine subroutines.  I do that all the time, and only for english.

 

To lighten your load, you could use language based string symbols...

(cond

  ((= language "english")

    (setq str1 "door") ;; etc.

  )

  ((= language "portuguese")

    (setq str1 "porta") ;; etc.

  )

)

John F. Uhden

0 Likes