AutoCAD Visual LISP / AutoLISP :: Last User Entered Command Needed As String Variable

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


ADVERTISEMENT

AutoCAD Visual LISP / AutoLISP :: Passing String As Variable?

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

AutoCAD Visual LISP / AutoLISP :: Removing A Character From A Variable / String

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

AutoCAD Visual LISP / AutoLISP :: How To Compare Value Of Variable To Set String Of Text

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

AutoCAD Visual LISP / AutoLISP :: Replacing Substr(s) In String Variable

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

AutoCAD Visual LISP / AutoLISP :: Command Line Variable

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

AutoCAD Visual LISP / AutoLISP :: Convert Variable To Command Name?

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

AutoCAD Visual LISP / AutoLISP :: Pass Command Line Variable

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

AutoCAD Visual LISP / AutoLISP :: Flip Variable / Command Line Won't Recognize After It Loads

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

AutoCAD Visual LISP / AutoLISP :: How To Detect User Hitting ESC Key During SAVEAS Command

Nov 8, 2011

I'm putting together a simple lisp routine to issue bound, purged drawings.

I have code that will do the binding & purging but need handling the saving.

This is my approach :

(1) ask the user to save the drawing using this line (command "_saveas" "" "~")

(2) run a subroutine that binds xrefs etc (this works ok)

(3) run the QSAVE command

Trouble is, if the user cancels or hits escape during the SAVEAS command the subroutine & QSAVE will still run, overwriting the current drawing. How do I handle this scenario? Or should my appoach be different?

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Changing String Of Text / Multitext / Dimensions To Another String

Nov 16, 2012

i failed to find one which would change string of a text to other for all types of objects. I mean it was usually either only multitext, or only text, dimensions or attributes.creating one which would change in abt 200 drawings:

-001

-002

-003

to:

-00001

-00002

-00003

in attributes, text, multittext, leaders, multileaders, dimensions..... at the same moment?

It is meant to be used in ScriptPro (by loading lisp in script).

If not possible, then can also open each file and run the lisp in each of them - still would save lot of time.

View 4 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Get Separate Block To Load If Third Number Entered When Prompted

Aug 23, 2011

I am wanting to get a separate block to load if a third number is entered when prompted. If enter is hit or only 2 of the numbers are entered, load the other block. I couldn't even get it to do right by even equaling a specific number.

View 8 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Add String To Each Item In List Using Lisp

Nov 14, 2013

I have a list ("temp.dwg" "temp2.dwg") and would like to add the string "insert text here" into each item in the list resulting in ("insert text heretemp.dwg" "insert textheretemp2.dwg").  how would i go about doing that using LISP?

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Convert To String ACL

Jun 6, 2012

I have a list that is "acl", I would like to convert it to a string "acl", everything that I have read uses alot of code. Does this  really take that much code to do?

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: List To String

Jul 11, 2013

Here's one that I could use on that i can't figure out:

I have a list of a bunch of descriptions that looks like this:

("00.02.00" "CTD01 Mainframe PT1 (top)" "GD01")

What I am doing is grabbing the middle item and i need to break this up into 2 lines.  So, my code below grabs the first 3 "words" in the second item in the list and puts them in a list, but I need to convert this back to a string.

(setq desc6a (list (car (read (strcat "(" (cadr input6) ")" )))(cadr (read (strcat "(" (cadr input6) ")" ))) (caddr (read (strcat "(" (cadr input6) ")" )))))

I tried a bunch of ways but can't get it

View 8 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Remove Portion Of A String?

Feb 22, 2012

I am trying to make this: L:Engineering-208037SURVEYDRAWINGS turn into this: L:Engineering-208037DRAWINGS

I am using the dwgprefix and it returns the first string and i want to make it in the second string as a new variable or replace the old variable so i can use it in a save as routine i am working on.

The problem is sometimes them project number (0208037) will be longer or shorter so i can't use the substr command

View 6 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Get Text String From Mtext?

Aug 20, 2013

I'm looking for a function to return the actual text from an mtext object.if there's a carraige return I wish to replace it with a space.

View 4 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Sorting A String Of Numbers

Aug 31, 2012

acad_strlsort will sorts strings, but what if my list looks like

("1" "2" "3" "10" "11" "12" "20")

i am sure i have seen it done ina simple way using vl-sort or vl-sort-i

but am not able to find...

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Check String To Set Up A Dimstyle

Nov 18, 2011

I've been working on a lisp to set up basic settings such as text styles, dim styles, discipline specific layers and things of that nature.

I have a prompt to ask for a discipline designator as a string.  I want to have an If statement or a conditional to read that string and check for a "C" if it finds it I want to have it set up a dimstyle to decimal feet ect and if not do it as architectural units.

This is just a test lisp that I'd like to add to the main one listed above...  

(defun c:test(/ disc dsnm dsna)

(setq disc (getstring "
Discipline (G,C,S,M,E,CP): "))                ;Prompt for Discipline
(setq ds (getint "
Dimscale Factor: "))                                          ;Prompt for Dimscale
[code].......

View 6 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Add Predetermined String To Each Layername In DWG

Aug 30, 2011

I'm working on a LISP function that adds a predetermined string to each layername in the dwg.

I came up with this:

(SETQ prefix "A-_82-_")
 (TBLNEXT "LAYER" T)
 (WHILE (SETQ la (TBLNEXT "LAYER"))
  (SETQ old (ASSOC 2 la)
     new (CONS 2 (STRCAT prefix (CDR old)))

[Code] .....

The line  (princ "
la is: ")(princ la) (princ "
") is thrown in to enable me to see the result of the while function, and is to be removed from the final version.

Now, everything seems to work fine, as the princ shows on the acad textstcreen.

Yet, when I check the layer palette, all layernames remain unchanged.

My guess is that I should use some other function then ENTMOD or ENTUPD to change the layertable, but I'm at a bit of a loss as to which function is required.

View 3 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Moving Attribute Block With Tag String Name

Dec 20, 2013

I have a lot of attribute blocks in my drawing which i want to move them one by one

so , here is what i want to do :

I have numbers (or texts) in my work area and this numbers also exist in my attribute blocks .. i wanna move my attribute blocks with tag name value reference to my specify area if tag name values are matching with text or numbers in this area .. every block will check my selected tag string and will be move on matching text in my work area.

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Convert Every Element Of List To String

Jul 17, 2012

I have a list of (0 .4 .8 0 10). I want to convert every element of the list to string.

View 4 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Create Layer Name In Attributes String Value

Oct 15, 2013

How i can filter attributes string value.

How i set the layer name is = attributes string value.

Example:

A attributes string value is R8 .all these string is set the layer name is same string value(R8).

View 1 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Find Duplicate Text String

Jun 11, 2007

In order to avoid duplicate text string in different places in the same drawing, I would like to have such a tool to find duplicate text string.

For instance, I want to put numbering of some connection lines, I do not want to have different lines but have same number by mistype.

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Get Tag String Of An Attribute By Mouse Clicking

Feb 24, 2013

I have a TitleBlock than contains more than 50 attributes inside itself.

I want to prepare a lisp code to GetTagString when I clicking on one attribute inside a BLOCK.

I prepare a code to get Block name when I ckick on a block:

(defun GetBlockName ( / obj)(defun sel_Obj( / sel)(While (=(setq sel (car (entsel "

choose a "BLOCK": ")))nil)(prompt "You didn't select any object!"))sel)(While (not (eq (vla-get-ObjectName (setq obj (vlax-ename->vla-object (sel_Obj)))) "AcDbBlockReference"))(prompt "That was not a "BLOCK"!"));;while (vlax-get-property obj (if (vlax-property-available-p obj 'EffectiveName) 'EffectiveName 'Name)) ) ;;usage: ;;(GetBlockName) ;;RESULT: ;;

just Selected Block Name Something like this but just for TagString of attribute is my desired!

View 3 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Add Or Subtract To Modify Value In Text String

Oct 18, 2011

I need a lisp routine that will add or subtract to modify a value in a text string. Its used for drainage fixture units on waste & vent plans. Example: We use basic dtext strings that look like this [color=red]4"(6)[/color]I would like to be able to add or subtract to the number that is [b][size=12pt]ONLY[/size][/b] in parenthesis and would like to be able to pick multiple text strings at one time so it would result in something like this: [color=green]4"(6)[/color] + 9 will become [color=blue]4"(15)[/color].

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Menu Link - Run IPE With String 270 When Click Amr

Feb 10, 2013

i have in Drive C a file "Steel.lsp" have function called IPE

in this function have this line 

(setq n (getstring "
Enter IPE Height :"))
 
i loaded it

i created a menu and command in it called "Amr"

no i need when i click Amr Run IPE with string 270 then click enter

i need all this happen automaticlly when i click on "Amr" on menu

how???

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Copy Text String From One File To Another

May 2, 2012

I have spent the last three days writing a lisp program that will copy a text string from one text file and paste it into another.  I have tried using the write-string, getstring, prin1, princ and print functions with no success. 

View 6 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Replace All Occurrences Of Character Within A String?

Sep 12, 2011

There is a lisp function to replace all occurrences of a character within a string?

In short, as the Replace command in Visual Basic

For example, to replace all "x" to "*":
"34x59+60x3" -> "34*59+60*3

View 6 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Asterisks In Variable Name?

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

AutoCAD Visual LISP / AutoLISP :: Set TARGET Variable

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







Copyrights 2005-15 www.BigResource.com, All rights reserved