AutoCAD Visual LISP / AutoLISP :: Storing Variable / Associate / Recall
Oct 24, 2013
I am looking for some way to store variables. For example in loop I want to
Enter a number
1
Enter hatch pattern
Ansi31
Enter a number
3
Enter hatch pattern
Ansi32
Enter a number
1
Enter hatch pattern <Ansi31>
Enter
Enter a number.... etc.
View 9 Replies
ADVERTISEMENT
Nov 15, 2013
I was just looking through one of Lee Mac's tutorials and I'm curious about something.
Here's a link to the tutorial I'm talking about.
[URL]
What is the purpose of the asterisks in the following code (marked in RED):
(if (not *ans*) (setq *ans* "Alpha"))
(initget "Alpha Beta Gamma")
(setq *ans*
(cond
(
(getkword
(strcat "
[code]....
View 4 Replies
View Related
Apr 23, 2013
I am trying to change the current TARGET variable to 0,0,0. If the variable is not changed is causes problems with plotting. I have the VBA that will change the TARGET variable. VBA works no problems. I am wanting to replicate in LISP because I do not want to have to convert to .NET and do not want to make sure the user has the VBA loded on thier system. Here is what have so far.
;;;Get active viewport
(setq avp (vla-get-ActiveViewport (vla-get-ActiveDocument (vlax-get-acad-object))))
;;;Get current TARGET variable
(setq CTarget(vla-get-Target avp))
Here is the problem. Is changing or putting the vaiable.I have tried
(vla-put-Target avp (vlax-3D-point '(0.0 0.0 0.0)))
and
(vla-put-Target avp (vlax-make-variant (vlax-3D-point '(0.0 0.0 0.0))(vlax-variant-type CTarget)))
They either error out or nil with no change. I have even tried to locate it in the Dictionaries.
View 5 Replies
View Related
Nov 11, 2011
There is a command in autocad that will get a Bounded Volume from a closed polyline and a volume surface (command "AeccReportSurfBoundedVolume"). It reports the results to the screen. How to get the "Net Volume" results in to a variable using Lisp?
Maybe a lisp routine that gets information from the text screen. That would not be ideal but I could work with that.
View 2 Replies
View Related
Sep 17, 2013
I've created a list and want to subtract all the values within it from another variable, and assign it to a new variable. How do I do it?
Basically, I ask for ground level (assigned to variable G1), and then any number of depths beneath that (assign to list LVLLIST), and I want to return the value of the bottom point. So it's all the values in LVLLIST added together and subtracted from G1. And assign it to a new variable BASE.
For example,
G1 = 650.00
LVLLIST = (1.23 23.26 0.13 50.23)
(setq BASE (- G1 LVLLLIST))
View 2 Replies
View Related
Nov 28, 2008
How to write some code which could create variable names like var1, var2, var3, etc. I need to do this because I have a large number to create and the actual number is variable and unknown.
Instead of manually writing a large number of line like
(setq var1 value1)
(setq var2 value2) etc
I used to be able to put 1 line in a loop to create and assign a large number of variables. I remember that it involved the use of the set (not setq) and read functions.
View 9 Replies
View Related
Feb 28, 2012
Is there anyway to program variable names?
What I was thinking of was in a loop some times I need multiple sets of similar variables but am not sure how many sets I am going to need. I would like to be able to increment the variable names each time the loop runs.
View 2 Replies
View Related
Feb 7, 2013
Somehow, I manage to turn of one variable that display errors on command line.
For example:
(seq a 6)
suppose to return, on command line, something like:
error no function definition: SEQ
View 9 Replies
View Related
Oct 10, 2008
A2008. Is there a setvar, setenv, registry entry etc. that can be used to change the scale of Multileaders with annotative off to have the same effect that DIMSCALE has on Q leaders? I want to have a single scale-independent Multileader style and modify it on the fly along with DIMSCALE and LTSCALE. I'd use Qleader but UCS's do odd things to text position and orientation.
View 4 Replies
View Related
Jul 9, 2013
I would like to use a string as a variable if this is possible. I've got:
new-pl-lay (as a variable that holds layer name "UGL_PL_NEW")
first-cable (as a string that holds "new-pl-lay")
I'd like set the current layer to "UGL_PL_NEW" by using the first-cable string.
Something like:
(command "_.layer" "m" (read first-cable) "")
View 8 Replies
View Related
Mar 12, 2012
I am trying to shorten my code by using the variable as the command name. Is that possible to do?
;; instead of this(cond ((eq USER_INPUT_ANSWER "blk-cdtree-01-06")(C:blk-cdtree-01-06)) ((eq USER_INPUT_ANSWER "blk-cdtree-01-08")(C:blk-cdtree-01-08)) ((eq USER_INPUT_ANSWER "blk-cdtree-01-10")(C:blk-cdtree-01-10)) ((eq USER_INPUT_ANSWER "blk-cdtree-01-12")(C:blk-cdtree-01-12)));; do something like this(C:blk-cdtree-(substr USER_INPUT_ANSWER 11))
View 8 Replies
View Related
Oct 20, 2011
how to write a lisp command, or function, that will save my newly created drawing with a file name is that is called up from a variable.
For example:
(setq filename variable)
(command "saveas" "r14" "filename")
and i would want the outcome to be: variable.dwg, rather than filename.dwg. I have tried numerous different ways of doing this with command prompt and cant seem to get anything to stick. Everything that works just creates a file named "filename.dwg", which is not what i want to do.
View 9 Replies
View Related
Nov 22, 2012
How do I check, with LISP, if a System Variable is read only? In particular ANNOTATIVEDWG. This one is read/write when there are no annotative objects in a drawing, but read-only if there are.
View 7 Replies
View Related
Oct 2, 2012
How come I can't modify the following registry key to the SAVEFILEPATH variable?
(vl-registry-write "HKEY_CLASSES_ROOT\SOFTWARE\Treadstone\File Sweeper" "NETWORK_LOCATION" SAVEFILEPATH)
View 1 Replies
View Related
Mar 8, 2013
I would like to create a lisp that does the following:
Update a titleblock attribute with a $variable.
The titleblockname is variable / not static.
The attribute is not variable / Static, DW_SCALE
The titleblock is always places on the same layer, BL$4----
The (custom)-plotscale is stored in the $var "gvpsc".
I've tried to ajust the following lisp code. But I couldn't extract the part I need.
The problem is, the code checks all the layouts and updates all the titlblocks one by one.
Truely a good code.
The only problem is, I don't have multiple layouts and I have a variable titleblock name.
Here is to code i've tried to convert to something I could use.
(defun C:UPD-DPC () (setvar "cmdecho" 0) (setq blkname "DPC-STEMPEL");(getstring "
Enter the name of block to update: ")) (setq att1 "DW_DATE");(strcase(getstring "
Enter the name of the attribute to change: "))) (setq newatt (strcase(getstring "
[Code] ....
View 9 Replies
View Related
Apr 26, 2012
I want to know if it's possible to replace a drive by an environment variable in a search path in the profile. For example:
to replace C:Program FilesAutodeskAutoCAD Mechanical 2012Acadm by %LOCAL DRIVE%Program FilesAutodeskAutoCAD Mechanical 2012Acadm.
View 5 Replies
View Related
Aug 28, 2009
I want to set the break size in all of my dimstyles but I can't find a system variable for it. know what it is or how else to set it?
View 2 Replies
View Related
Mar 21, 2012
I have this small lisp routine:
(defun c:1p nil
(command "_.-plot" "yes" "" "controls 11x17" "Ledger (11 x 17)" "inches" "LANDSCAPE" "NO" "view" "01" "FIT" "CENTER" "YES" "newpap2.ctb" "YES" "As" "NO" "NO" "yes" )
(princ)
)
I want to use it to plot different views which I will append to the command when it is called from within AutoCAD.This code will, of course, print view one.Currently my worst case is 25 views and, for that situation, I have simply repeated this code 25 times with a different function name an view number for each view. Eventually I would like to make a dialog box that would allow me to select with checkboxes (toggles) the views to print and with a button to print all.
For example, if I wanted to plot view 25, after I had loaded this lisp routine I would enter, on the command line in AutoCAD, the function name ("pp" perhaps?) followed by some variable (in this case 25, but could be any view name. ie. 01, elev, detail) and the view name would be inserted at the appropriate place.
View 3 Replies
View Related
Oct 24, 2011
I am using a variable that is being called up from a .csv file for a file name. By default this variable automatically includes a comma due to it being called from a .csv.
How to remove a character ( , ) from a variable? I'm not sure if this is along the right line or not, but i used the READ function to read the variable as a string (i think thats how it works?).
View 9 Replies
View Related
Jun 11, 2012
I would like to know how I can compare the value of a variable to a set string of text if the two prove to be equal perform task A if the two prove different perform task B?
View 7 Replies
View Related
Feb 18, 2013
I write a code to replace strings in one string.for example
str="AutoDesk, AutoCAD, 2013, Electrical, 64Bit"
patt=", "
NewStr=" - "
==> result: "AutoDesk - AutoCAD - 2013 - Electrical - 64Bit"
;;replaces NewStr instead of Patt(s) in Str string(defun ReplaceStr (NewStr Patt Str)(While (> (vl-string-search ptt str) 0)(setq Str (vl-string-subst NewStr patt Str)) );;whilestr) ; usage;(ReplaceStr " - " ", " "AutoDesk, AutoCAD, 2013, Electrical, 64Bit")
==> result= ; error: bad argument type: (or stringp symbolp): nil
View 9 Replies
View Related
Oct 4, 2012
I have attached 2 lisp files. datblkx5 makes a block of selection, inserts the block with a 5x distortion, explodes it, and corrects the text for width factor and text height. This one works fine.
I wanted to add the feature of scaling my selection with a user input value. This is the lisp datblkxxx. This one doesn't work. (that is it doesn't correct the text for width factor). I can't figure it out.
View 3 Replies
View Related
Dec 30, 2013
Is it possible to change the system variable "TEXTSIZE" with an autolisp routine? I have hundreds of drawings that have varying textsize settingings and I can't get it to let me change it, unless I go into "Style" and manually change the value to "0" before I run the routine, and there are simply too may drawings to do that everytime. So, is there a way to reset the textsize to 0 through Lisp?
View 5 Replies
View Related
Jun 14, 2013
I am writing a LISP program to generate development of surfaces. Once the entire drawing is completed, I want that the input data to be displayed on drawing window as text.
View 2 Replies
View Related
Oct 3, 2012
When scrolling through the list of variables (accessed through the commands prompt -> Setvar ->?
->*)
that all variables pointing to a path show backslashes except for SAVEFILEPATH.
View 5 Replies
View Related
Apr 5, 2013
I'm looking for a way to find out what all plot styles are set in drawings in a sheet set.
We are transitioning from color based pen settings to style based and would like to be able to export a log that shows the variable PSTYLEMODE for each drawing in a sheet set. I plan on using ScriptPro to run it on the full sheet set.
Civil 3D 2013
Windows 7 64-bit
Xeon W3550 3.07 GHz
Nvidia Quadro 4000
12.0 GB RAM
View 2 Replies
View Related
Feb 22, 2012
how to append I’m assuming its not write-line but append line. And also I’m having trouble recording the date variable… I keep getting error bad argument type stringp nil
; Appends usage count by DATE long variable...(setq g(open "C:/ICT/AutoCAD_Architecture_suite_2012/CUSTOM/WOOD Clones/PEN/USSAGELOG.PEN" "w"))(setq MYDATE DATE)(write-line MYDATE g); AS ABSOLUTE LAST WE NEED TO CLOSE THE TEXTFILE...(close g)
I have the following code snippet I’m trying to append the file named USAGELOG.TXT to record the date of executions
View 2 Replies
View Related
Aug 25, 2011
I have to obtain a selection set of blocks (by window selection and/or single-picks if the user desires) and then an attribute value which I have previously assigned to a variable called TAGVAL to the attribute tag name called PART in that selection set of blocks.
I found a cool routine called RepAtt, but it isn't quite set up to do what I need...
(defun RepAtt (Tag / SourceBlk ValueToCopy SelSet) (vl-load-com) (if (setq SourceBlk (car (entsel "
Select Source Block:"))) (progn (mapcar '(lambda (p) (if (equal (vla-get-tagstring p) Tag) (setq ValueToCopy (vla-get-textstring p)) ) ) (vlax-invoke (vlax-ename->vla-object SourceBlk) 'GetAttributes ) ) (ssget ":L" '((0 . "INSERT") (66 . 1))) (vlax-for DesBlock (setq SelSet (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)) ) ) (foreach att (vlax-invoke DesBlock 'GetAttributes) (if (equal (vla-get-tagstring att) Tag) (vla-put-textstring att ValueToCopy) ) ) ) (vla-delete SelSet) ) ) ) (RepAtt "WIDGET");<-- Tag Name
View 1 Replies
View Related
Nov 15, 2012
I am trying to create a custom message box with variable width and height by passing width height title and list of text. I can get the routine to work if I use preset width and height, but would like to make the box adjustable.
Here is what I have so far -
;--dialog box--
MYmessage :dialog{
label="Custom message box";
:column {
:text {
key="MY_message_Title";
fixed_width_font=true;
[code].......
View 3 Replies
View Related
Aug 1, 2013
Main question: I need the user to be able to type a command. Then use it or cancel it. Then i need them to type another lisp command. In the second command i need to know (have the string of) the previous command they typed in. How do i get that string?
What I have tried.
I have looked at "LASTPROMPT" though not extensively, and i believe it would just return "ineedhelp" if i tried that.
I have looked at "CMDNAMES" but that gives the command you're currently in.
And I have found one page on this forum titled: Command Line History Macro, but there was no answer on that post.
I could create a global variable for that string, but then I would have to put the set code in every function I create. Nope, will not.
Backstory:
There's a person that is going to make how-to videos on how to use some of my lisp routines.
Anyhow, I need the user to be able to type in "ineedhelp" and the lisp that runs must get the last command's string go to the shared drive and pull up the video file for that command.
I have made a lisp that opened a word file before, and if i could get the string of the previous command, i'm fairly certain that I can get the videos to work.
There will be approximately 60 lisp routine video's.
View 9 Replies
View Related
Nov 14, 2012
I'm trying to make an autolisp that "flips" a third party variable. No luck, command line won't recognize after it loads. I've made similar variable flips that work ??
(defun c:wp (/ wp)
(setq wp (getvar "kti_archt_wallpoche"))
(if (= kti_archt_wallpoche 0)(setvar "kti_archt_wallpoche" 1)
(if (= kti_archt_wallpoche 1)(setvar "kti_archt_wallpoche" 0)
View 2 Replies
View Related