Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Variable in get functions

7 REPLIES 7
Reply
Message 1 of 8
dicra
1449 Views, 7 Replies

Variable in get functions

Hi all,

 

I'm having one question.

Is it possible to answer whit variable in get functions, for example, If program is asking for getreal, can user answer, somehow, whit variable in which one is stored real value. Or whit something like this (/ 10. 2)

Normally if user answer whit variable, he get "Requires numeric value."  

 

Thanks for answers

 

7 REPLIES 7
Message 2 of 8
hmsilva
in reply to: dicra


dicra wrote:

Is it possible to answer whit variable in get functions, for example, If program is asking for getreal, can user answer, somehow, whit variable in which one is stored real value. 


Hi dicra,

 

if you already have the value stored in a variable, you can use something like this:

i.e.

(setq YourVariable 10.0)

...

(setq ans (getreal (strcat "\nEnter a real number <" (rtos YourVariable) ">: ")))
(if (not ans) (setq ans YourVariable))

 

If the user just press enter, accepting the default value, the ans will be nil, so we'll need to set ans with YourVariable value.


dicra wrote:

Is it possible to answer whit variable in get functions... whit something like this (/ 10. 2)


No.

From the help files:

"The user cannot enter another AutoLISP expression as the response to a getreal request. "

 

HTH

Henrique

EESignature

Message 3 of 8
dicra
in reply to: hmsilva

Henrique,

 

Thank You for answer.

Your are saving me a lot of time...

 

I'm trying to speed up process of using one program, which of course I can't modify (fas files).

So, I was thinking about to use some of those commands in my lisp.

Is it possible to something like that, maybe with script or something. I could write a script using lisp, and then to run it in same routine.

I noticed that with script I can pass the real values which I want, but can I select the entities using script. I suppose to select an entity and then to forward some real values for that command, like this:

 

"script_command" "select_entity" "real_value" "real_value" 

 

 

Message 4 of 8
hmsilva
in reply to: dicra


@dicra wrote:

Henrique,

 

Thank You for answer.

Your are saving me a lot of time...

 

I'm trying to speed up process of using one program, which of course I can't modify (fas files).

So, I was thinking about to use some of those commands in my lisp.

Is it possible to something like that, maybe with script or something. I could write a script using lisp, and then to run it in same routine.

I noticed that with script I can pass the real values which I want, but can I select the entities using script. I suppose to select an entity and then to forward some real values for that command, like this:

 

"script_command" "select_entity" "real_value" "real_value" 

 

 


You're welcome, dicra!

 

Using a script, if you mean a .scr file, you can't stop de file to select objects....

 

Using a routine, you 'possibly' may call another routine and input the required values, for example the 'demo' routine is the .fas

 

(defun c:demo (/ c ss)
  (if (and (setq ss (ssget))
	   (setq c (getint "\nEnter color number: "))
	   )
    (command "_.chprop" ss "" "_C" c "")
  )
  (princ)
)

 and the 'test' routine is the code to call the demo and and input the required values

 

(vl-load-com)
(defun c:test (/ c d ss)
  (if (and (setq ss (ssget))
	   (setq c (getint "\nEnter color number: "))
	   (setq d (itoa c))
      )
    (vla-sendcommand
      (vla-get-activedocument (vlax-get-acad-object))
      (strcat "demo\rP\r\r" d "\r")
    )
  )
  (princ)
)

 load both routines and type test...

 

HTH

Henrique

EESignature

Message 5 of 8
dicra
in reply to: hmsilva

Thank you Henrique,

 

This is really helpful.

I was thinking about similar, but whit using .scr file. Idea was to make selection set, and later to use Previous in selection set.

Your idea is a lot more better, then using .scr file.

 

There are some things which I need to test, in my routine, and to check if this is going to solve the problem.

On first look, I'm seeing some problems, because I think that this program is using nearest point, to be sure to select the point exactly on object.

And another problem might be, if user need to select two objects, first one, then another.

I will try your idea on several programs which I would like to use in my lisp.

Message 6 of 8
stevor
in reply to: dicra

Could make a lisp routine to load your variables

or get values for them,

and write the script file,

and execute the fas.

S
Message 7 of 8
pbejse
in reply to: dicra

 


@dicra wrote:

Hi all,

 

I'm having one question.

Is it possible to answer whit variable in get functions, for example, If program is asking for getreal, can user answer, somehow, whit variable in which one is stored real value. Or whit something like this (/ 10. 2)

Normally if user answer whit variable, he get "Requires numeric value."  

 

Thanks for answers

 


Interesting topic. Why the need for a function to do this? (curious is all)

 

Message 8 of 8
dicra
in reply to: pbejse

Hi all,

 

Thank you for interesting in my problem.

 

Sorry I didn't answer earlier, extremely busy these days.

Because of that I didn't have enough time to deal whit this problem, too. For the problem which I had, I solved it on way that I rewrited the program which is going to do the same thing as the .fas which I'm using.

 

pbejse,

reason why I want to do that, is because I'm using, on a daily basis, one software which is having a dozens of commands. All commands are in .fas files or arx files.

To better present my problem, imagine that one of those command is similarly like autocad "fillet".

Because it is a .fas file, I can't do something like this:

(command "fillet" ename1 ename2)

So I need to find another solution, because sometime I need to do same command for dozens of times.

 

Henrique's idea with vla-sendcommand and previous selection set is working fine, but  only when I need to provide one selection set (or string, real, integer).

Problem is when program ask for two entities (first one then another) like with fillet command, or when user need to give a point whit selected object, because like in fillet it is not same, on which end of entity will user select.

 

Stevor,

I was thinking the same thing, but I think vla-sendcommand is better solution.

And there is the same problem with script if I need to select more then one entities (previous selection se t is not the solution) I need to provide two separate enames.

 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost