TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Atwist on June 17, 2010, 02:11:59 AM
-
Hello forummebers,
I would like a screen with input calculation items.
Then this insert as text item .
Example
Area x pressure = max load
Is this possible?
Sorry for my bad english
-
try to use TABLE
see attached
-
HasanCad,
Thanks for answer.
This is no option for my Il have the calculation white text insert the drawing
-
Please upload a sample file.
-
A simple solution, No error checking!
(defun c:test (/ area pres force pt ent)
(if
(and
(setq area (getint "\nEnter the Area: "))
(setq pres (getint "\nEnter the Pressure: "))
(setq force (* area pres))
(setq pt (getpoint "\nSpecify the text location."))
(setq ent (entmakex
(list '(0 . "TEXT")
(cons 10 pt)
;(cons 40 1)
(cons 7 (getvar "TEXTSTYLE"))
(cons 1 (vl-princ-to-string force))
)
)
)
)
(princ "\nText Created")
(princ "\n<!> No Text Specified <!>")
)
(princ)
)
-
CAB beat me for that :)
(defun c:test (/ area press force pt ent)
(if
(and
(setq area (getreal "\nEnter the Area: "))
(setq press (getreal "\nEnter the Pressure: "))
(setq force (* area press))
(setq pt (getpoint "\nSpecify the text location."))
(setq ent (entmakex
(list (cons 0 "TEXT")
(cons 10 pt)
(cons 40 (if (zerop (getvar "TEXTSIZE")) 2.0 (getvar "TEXTSIZE")))
(cons 7 (getvar "TEXTSTYLE"))
(cons 1 (strcat (rtos area 2 3) " x " (rtos press 2 3) " = " (rtos force 2 3)))
)
)
)
)
(princ "\nText Created")
(princ "\n<!> No Text Specified <!>")
)
(princ)
)
~'J'~
-
Cab & fixo,
Il have this error
test.lsp successfully loaded.
Command: ; error: bad argument type: numberp: nil
Command: ; error: bad argument type: numberp: nil
Command:
Whats is wrong
-
Working good for me
Command: appload
areatext.LSP successfully loaded.
Command:
Command:
Command: test
Enter the Area: 100.05
Enter the Pressure: 2.89
Specify the text location.
Text Created
~'J'~
-
another code...
e.fernal
;|
/* DIALOG FILE */
dialogo:dialog{label="Area x Pressure";width=36;fixed_width=true;
:spacer{height=0.5;}
:row{alignment=centered;fixed_width=true;
:column{
:text{label="Area";}
:edit_box{edit_width=12;key="area";action="(CALCULATE_AREA_PRESSURE)";}}
:column{
:text{label="Pressure";}
:edit_box{edit_width=12;key="pressure";action="(CALCULATE_AREA_PRESSURE)";}}}
:text{label="";key="result";alignment=centered;width=28;fixed_width_font=true;}
:spacer{height=0.5;}
ok_only;}
|;
(DEFUN c:apr (/ dh ar pr re CALCULATE_AREA_PRESSURE)
;; ***********************************************
(DEFUN calculate_area_pressure ()
(SETQ ar (ATOF (GET_TILE "area"))
pr (ATOF (GET_TILE "pressure"))
re (* ar pr)
)
(SET_TILE "result" (STRCAT "Result = " (RTOS re 2 4)))
)
;; ***********************************************
(IF (> (SETQ dh (LOAD_DIALOG "dialogo.dcl")) 0)
(IF (NEW_DIALOG "dialogo" dh)
(PROGN
(set_tile "result" "Type and press ENTER")
(START_DIALOG)
(UNLOAD_DIALOG dh)
(IF re
(IF (SETQ p1 (GETPOINT "\n-> Insertion point : "))
(ENTMAKE
(LIST
(CONS 0 "TEXT")
(CONS 1 (STRCAT (RTOS ar 2 4) "x" (RTOS pr 2 4) "=" (RTOS (* ar pr) 2 4)))
(CONS 10 p1)
(CONS 40 (GETVAR "TEXTSIZE")) ; change if desired, EXAMPLE (cons 40 15.0)
(CONS 50 0.0)
)
)
)
)
)
nil
)
(ALERT "Error:\n\n\tUnable to load dialog!\t\n\n")
)
(PRINC)
)
[edit:kdub:codeTagsAdded]
-
efernal (http://www.theswamp.org/index.php?topic=4429.0)
-
hello,
I'm stuck, I created the following using http://web2.airmail.net/terrycad/Tutorials/MyDialogs.htm
Dialog is good but I do not know how to calculation and how I put this in the drawing.
The calculation shall then be in a text block
Sorry for my bad english
-
I'm not sure about I've used right formula
because of don't understand what you exactly mean
Better yet attach a picture with resulting text
Say,
Cilinder diameter = 10.0
Werkdruk =5.0
What is the text should on screen?
(defun edit_action (val why)
(if (or (= why 1) (= why 2))
(set_tile "Edit3" val)
)
)
(defun c:cil (/ Dcl_Id% Edit1$ Edit2$ Edit3$ Return#)
(princ "\n >> cil")
(princ)
; Set Default Variables
(if (not *cil@) ;Unique global variable name to store dialog info
(setq *cil@ (list nil "" "" ""))
) ;if
(setq Edit1$ (nth 1 *cil@)
Edit2$ (nth 2 *cil@)
Edit3$ (nth 3 *cil@)
) ;setq
; Load Dialog
(setq Dcl_Id% (load_dialog "cil.dcl"))
(new_dialog "cil" Dcl_Id%)
; Set Dialog Initial Settings
(set_tile "Title" "Cilinder berekening")
(set_tile "Text1" "Cilinder diameter")
(set_tile "Edit1" Edit1$)
(set_tile "Text2" "Werkdruk");;pressure
(set_tile "Edit2" Edit2$)
(set_tile "Text3" "Diameter zuigerstang") ;;stiffners diameter
(set_tile "Edit3" Edit3$)
; Dialog Actions
(action_tile "Edit1" "(setq Edit1$ $value)")
(action_tile
"Edit2"
(strcat
"(progn "
"(setq Edit2$ $value)"
"(edit_action (rtos (/ (atof Edit2$) (/ (* pi (expt (atof Edit1$) 2)) 4) ) 2 3) $reason)"
"(mode_tile \"\" 2))"))
(action_tile
"accept"
(strcat "(progn "
"(setq Edit1$ (get_tile \"Edit1\"))"
"(setq Edit2$ (get_tile \"Edit2\"))"
"(setq Edit3$ (get_tile \"Edit3\"))"
"(done_dialog 777))"))
(setq Return# (start_dialog))
; Unload Dialog
(unload_dialog Dcl_Id%)
(if (= 777 Return#)
(progn
(setq pt (getpoint "\n >> Pick insertion point of text >>"))
(entmakex (list (cons 0 "TEXT")
(cons 10 pt)
(cons 40
(if (zerop (getvar "TEXTSIZE"))
2.0;<--- default text size, change to suit
(getvar "TEXTSIZE"))
)
(cons 1
(strcat (rtos (atof Edit2$) 2 3)
" / "
(rtos (/ (* pi (expt (atof Edit1$) 2)) 4)2 3)
" = "
(rtos (atof Edit3$) 2 4)))
)
)
)
)
(setq *cil@ (list nil Edit1$ Edit2$ Edit3$))
(princ)
);defun c:cil
~'J'~
-
Hello Fixo,
Thanks for answer
Its don't works.
cil.lsp successfully loaded.
Command: ; error: malformed list on input
Command: ; error: malformed list on input
Command:
But il have the XL lisp from JPsanders. and that works for my oké
Thanks
-
Hello Fixo,
Thanks for answer
Its don't works.
cil.lsp successfully loaded.
Command: ; error: malformed list on input
Command: ; error: malformed list on input
Command:
But il have the XL lisp from JPsanders. and that works for my oké
Thanks
:pissed:
I just copied my code from the thread above and
it works nice on my machine:
Command: appload
cil.lsp successfully loaded.
Command:
Command:
Command: cil
>> cil
>> Pick insertion point of text >>
Forgot to say, after you'll enter value into "Werkdrug" box you
need to press Enter to calculate data in the last box
~'J'~