All Activity
- Today
-
Strydaris started following How to deploy list of Lisps to everyone in the organisation - AutoCAD LT
-
How to deploy list of Lisps to everyone in the organisation - AutoCAD LT
Strydaris replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
@CivilTechSource I'm not as good at the whole CAD customization as some or maybe all of the guys in this thread but here is what I do at my office. 1) I get everyone to add a line to their Support File Search Path. The line I get them to add is located on our server so everyone has access to it. For example my line is "G:\Support_Files\Autolisp\_LoadOnStart" where the G:\ is a network drive and the Autolisp folder contains all our Autolisps. 2)I add the same folder into the Trusted Locations section. Or in this case I would just this line. "G:\Support_Files\Autolisp\..." The 3 periods at the end means also include every folder here after. 3) Once thats all setup then AutoCAD should start loading all acad.lsp & acaddoc.lsp or acadlt.lsp & acadltdoc.lsp when you start CAD or open a file. 4) I created an acadltdoc.lsp file and put my load, autoload or system variables in there. Here is a small snippet of what I load when users open a file.... Here is what I do for system variables and to make sure they are the same across the company. Doing this has helped and has decreased the amount of times I get asked why something isnt working. I have more variables then written here. This is just an example. ;;Set system variables that need to be set for Cassidy & Co CAD Standards (defun-q MYSTARTUP () (SETVAR "REGENMODE" 1) (SETVAR "GRIDMODE" 0);Turns off the grid (SETVAR "SNAPMODE" 0);Turns off snap to grid (SETVAR "MIRRTEXT" 0);Text will mirror (SETVAR "BINDTYPE" 1);Changes Xref Bind types. ie Setting to 1 will remove the xref files name from the layer name. (SETVAR "DIMASSOC" 1);Sets dims to be non-associated to objects (SETVAR "VISRETAIN" 1) (SETVAR "FILEDIA" 1);Yes (SETVAR "ATTDIA" 1);Yes (SETVAR "ATTREQ" 1);Yes (SETVAR "INSBASE" (list 0.0 0.0 0.0));Yes (SETVAR "SAVETIME" 10) (SETVAR "XREFNOTIFY" 2) (SETVAR "TRANSPARENCYDISPLAY" 1) (SETVAR "FIELDEVAL" 31) (PRINC) ) For LISP Routines I do this..... (setq S::STARTUP (append S::STARTUP MYSTARTUP)) (load "G:/Support_Files/Autolisp/SubFunctions.lsp") (load "G:/Support_Files/Autolisp/_LoadOnStart/TipV1-1.lsp") ;;Areas (autoload "G:/Support_Files/Autolisp/Area Calcs/Areas2AttributeV1-2.lsp" '("A2A")) (autoload "G:/Support_Files/Autolisp/Area Calcs/Areas2FieldV1-3.lsp" '("A2F")) The LOAD section will directly load the Lisps as the file loads. The AUTOLOAD section will load the lisp when the command at the end is written. For example if A2A or A2F typed out then the lisp will load and run the command. -
Hiding LISP code in CUI button
Strydaris replied to Strydaris's topic in The CUI, Hatches, Linetypes, Scripts & Macros
@CivilTechSource You could do it that way, but I wouldnt . I would use the built in Styles and have the user select which style to use. If using AutoCAD you should expect the user to have a certain level of usability in the work space. If they dont have the level then do not make it easier for them, make them use CAD the way its intended. By doing that you are making sure that they learn CAD and also use the office CAD Standards how they are intended to be used. -
increase or decrease value of attdef...help
leonucadomi replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
EXCELLENT MASTER , THANK YOU -
Hiding LISP code in CUI button
CivilTechSource replied to Strydaris's topic in The CUI, Hatches, Linetypes, Scripts & Macros
That is really handy to know! Would it be wise to create a Textbox in the CUI where the user can input a number eg. text height and then all lisps that run can use the text height specified globally? -
Why does using a variable for a T/nil outcome in an if statement make it go screwy?
ESan replied to ESan's topic in AutoLISP, Visual LISP & DCL
Does the first set of code not automatically check for a nil option? From my understanding, the if function has a T and nil outcome and needs both to work. If the statement is true, carry out the first (T) option, if not, carry out the second (nil) option. -
Why does using a variable for a T/nil outcome in an if statement make it go screwy?
ESan replied to ESan's topic in AutoLISP, Visual LISP & DCL
Ah, I wasn't 100% sure if it was or not. When I was testing this out, my command was just "OK". I thought I would change it to something more appropriate for clarity. Does the if function not automatically evaluate the T and nil outcomes? Using eval in place of just the variable does fix the issue when printing to the command line, however it does not work when asking it to perform an action, such as changing the users layer if inp does not equal1. If 1 is entered, it will show the correct evaluated option in the command line, but carry out the nil value regardless- changing the users layer as well. I might be trying to understand the if function in a situation where it is not realistically used. But I am not sure I know enough to know that either -
Why does using a variable for a T/nil outcome in an if statement make it go screwy?
ESan replied to ESan's topic in AutoLISP, Visual LISP & DCL
I did not know that was a feature, sorry about that!! -
This one is great! I'd love to see the updated one when its ready. I didn't realize I had tried it with the other version, but this one works great. Thanks again
-
Why does using a variable for a T/nil outcome in an if statement make it go screwy?
rlx replied to ESan's topic in AutoLISP, Visual LISP & DCL
oh posted at the same time as pkenewell :-) -
rlx started following Why does using a variable for a T/nil outcome in an if statement make it go screwy?
-
Why does using a variable for a T/nil outcome in an if statement make it go screwy?
rlx replied to ESan's topic in AutoLISP, Visual LISP & DCL
first of all , if is a built in command so c:if I don't think works second , yes and no are variables not functions so you could use (setq yes "\nYes") and then use (eval yes) better would be : (defun c:whatif (/ inp yes no) (setq yes "Yes" no "No") (if (= (setq inp (getint "\nValue: ")) 1)(eval yes)(eval no)) ;;; or (if (= (setq inp (getint "\nValue: ")) 1)(princ "\nyes")(princ "\nNo")) (princ) ) -
pkenewell started following Why does using a variable for a T/nil outcome in an if statement make it go screwy?
-
Why does using a variable for a T/nil outcome in an if statement make it go screwy?
pkenewell replied to ESan's topic in AutoLISP, Visual LISP & DCL
If you want to use an IF statement with a variable that could be something or NIL, simply use this construct: (defun C:IF () (setq i (getint "\nEnter a Number or ENTER for nothing: ")) (if i ;<-- If not nil (progn (princ (strcat "\nYou entered the number " (itoa i) ". ")) T ) (progn (Princ "\n You did not enter anything. ") nil ) ) ) Conversely if you want to check for a NIL condition: (defun C:IF () (setq i (getint "\nEnter a Number or ENTER for nothing: ")) (if (not i) ;<-- If nil (progn (Princ "\n You did not enter anything. ") nil ) (progn (princ (strcat "\nYou entered the number " (itoa i) ". ")) T ) ) ) -
Yes, that had some issues, I think I have that sorted, but not ready to repost. Still working on adding the DCL to it. It happens to me all of the time. No worries!
-
Why does using a variable for a T/nil outcome in an if statement make it go screwy?
SLW210 replied to ESan's topic in AutoLISP, Visual LISP & DCL
Please use Code Tags for your code in the future. (<> in the editor toolbar) -
jamami started following How to stop attributes from mirroring in nested blocks
-
How to stop attributes from mirroring in nested blocks
jamami posted a topic in AutoCAD Drawing Management & Output
I have recently updated a batch of blocks changing all labels from text to attributes, the idea being to stop them mirroring. After competing this task I find that the attribute text still mirrors. I think it is because the attributed blocks are nested. Is there any way to stop this? The attached block shows the issue. jam2.dwg -
Adding data to property lookup tables
jamami replied to jamami's topic in AutoCAD Drawing Management & Output
Hi This is a pretty complex block attached. All the parts are spaced out at mo while I am getting things working, once done they are all moved in line. We make beams 2,3,4,5&6m lengths. To make up 7m we use 4+3, to make up 8 we use 5+3, 9-5+4, 10-6+4, ....13-6+4+3 etc etc. i have defined the available viz states Issue is we terminate the beam ends in 1 of 3 ways also we run beams lengths upto 50m at times. Only 1 viz state allowed in autocad (although i did see a link containing a block with multiple viz states but i think that involves some pretty high end programming skills), so I have been playing with using dummy parameters. It works well (attached). My issue is that I need to create many many hundreds of lines of data to encompass the full range I am looking for . jam1.dwg -
ESan started following Why does using a variable for a T/nil outcome in an if statement make it go screwy?
-
After being stuck on this subject for a while, I know the answer is "don't use variables for the actions of an if statement" but I am still bothered as to WHY it does not work. I assume it has to do with the way the if function evaluates, but I cannot figure it out myself. I apologize in advance for the long read. For example, I created a short routine to give a positive or negative response dependent on whether or not the user input equals 1: (defun c:if (/ inp) (setq inp (getint "\nValue: ")) (if (= 1 inp) (print "You Did It!!!!!!!!!") (print "You FAILED") ) (princ) ) This routine works- I provide the action for the T or nil outcome within the if statement. However, if I assign variables instead: (defun c:if (/ inp yes no) (setq inp (getint "\nValue: ") yes (print "You Did It!!!!!") no (print "You FAILED") ) (if (= 1 inp) yes no) (princ) ) The routine doesn't know what to do with itself regardless of user input. It returns the nil outcome twice regardless of whether or not the user input value equals 1. I do not understand why it skips to the nil outcome if the statement is true.
-
After seeing your post I realized I was trying it with the wrong LISP. I was trying it with TMTMS and that was giving me the results that had the space and wasn't numbering anything. Just tried it with this one 'FNRSEQ' and it works perfectly. Thank you so much for this.
-
Thanks for this, learned something new, much cleaner and easier. I tried your suggestion, but didn't work, I also did some more testing and the reading of the data is done properly, the appending of the new content is done properly, and then I think the problem occurs when creating safearray using value 17 or in other words using VisualLisp variant data type vlax-vbByte, which is unsupported according to this post. So the value that has been returned from vlax-variant-type performed on result of reading with (LM:ReadBinaryStream (findfile "../AppAutoLoad.app") nil) is 8209 which is value of vlax-vbArray(8192) combined with vlax-vbByte(17), but since the vlax-vbByte data type seems to be unsupported I guess that I can't recreate the variant of the same type (8209) anymore?
-
Block definition modification - adding 2 attributes.
pefi replied to pefi's topic in .NET, ObjectARX & VBA
Thank you very much! I'm not sure if I understand you, you mean reading excel directly using AutoLISP? I never tried to do anything with excel and LISP together. When I have data in excel I use VBA and calling LISP scripts from VBA. The sample data set attached - there are 4 columns, file, bhd_ins - block handle that needs to get the "data injection", bhd_type and bhd_line - are the names of attributes in that block. The block handles in the sample set correspond to the real handles on the sample drawing. The content of bhd_type and bhd_line is made up, but that won't make a difference. sample_drawing.dwg handle_table.xlsx -
FWIW, you can change this: (mapcar 'ascii (MM:strToLst text)) To: (vl-string->list text) An untested suggestion: where the variant is concerned, rather than using hardcoded variant & safearray datatypes, try querying the types of the original variant & safearray using: vlax-variant-type vlax-safearray-type
-
Thanks for advice, I tried that already but no success, it seams like is not possible to write to binary files using standard write-line command. That's why I went from this solution from Lee Mac which is using ADO Stream object and it works fine when reading with LM:ReadBinaryStream and then writing the result of that function (whic is vlax-variant) back to the file using LM:WriteBinaryStream, but when I try creating my own vlax-variant object and write it back to the file it doesn't go as expected. Yes. it does, I'm using them in my code, but problem occurs while building vlax-variant object which is needed for writing data back to the file, somehow only zeroes are written and I can't figure out why.
-
increase or decrease value of attdef...help
BIGAL replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
Another go. (defun c:addval ( / lst lst2 att cnt lst3) (setq inc (getreal "\nEnter increment + or - ")) (setq ss (ssget '((0 . "TEXT,ATTDEF")))) (setq lst '() tnum 0 tatt 0) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x))))) (setq objname (vlax-get obj 'objectname)) (if (= objname "AcDbText") (progn (setq newt (+ (atof (vlax-get obj 'textstring)) inc)) (cond ((< newt 10 ) (setq newt (strcat "00" (rtos newt 2 0)))) ((< newt 100) (setq newt (strcat "0" (rtos newt 2 0)))) (setq newt (rtos newt 2 0)) ) (vlax-put obj 'textstring newt) (setq tnum (1+ tnum)) ) (progn (setq newt (+ (atof (vlax-get obj 'tagstring)) inc)) (cond ((< newt 10) (setq newt (strcat "00" (rtos newt 2 0)))) ((< newt 100) (setq newt (strcat "0" (rtos newt 2 0)))) (setq newt (rtos newt 2 0)) ) (vlax-put obj 'tagstring newt) (setq tatt (1+ tatt)) ) ) ) (alert (strcat (rtos tnum 2 0) " text changed \n" (rtos tatt 2 0) " tags Changed")) (princ) ) -
Hiding LISP code in CUI button
Strydaris replied to Strydaris's topic in The CUI, Hatches, Linetypes, Scripts & Macros
@CivilTechSource Yes you can make the variable global by not clearing it in the lisp routine. If you aren't familiar with what I am taking about in a lisp you write at the top this.. (defun c:lisp ( / variable1 variable2) ) If you set a value to variable3 as long as it's not in the list like variable1 is then it's consider a global variable which can be used by multiple lisps. Typically I see people use something like global:variable1 to know which is which. Hope that helps. -
Block definition modification - adding 2 attributes.
BIGAL replied to pefi's topic in .NET, ObjectARX & VBA
You mention reading from Excel, its not a problem you can read cells from CAD, so if you have multiple blocks can be done. It would be simple to add to your defun say two columns in Excel Blocknames & dwgname with path. Need a sample Excel. -
Hiding LISP code in CUI button
BIGAL replied to Strydaris's topic in The CUI, Hatches, Linetypes, Scripts & Macros
A suggestion use a "\n" in the (getreal "\nEnter Rise...) this will push a new line on the command line. If the F2b is a global variable then any lisp can read it, but that is not necessarily a good idea. Its easier to do a double lisp in the cui. So load the program and call a defun passing it the f2b value. ^C^C^P(setq F2B (getreal "Enter Rise for Front to Back slopes: "))(load "mylisp")(mylisp f2b) I use LDATA when I want values stored in a dwg they stay in the dwg and can be changed.