AutoCAD Visual LISP / AutoLISP :: Subtracting List From A Variable
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.
I have been asked to make the title text larger (drawing are being issued at 1/2 scale, A1 to A3) on a large set of drawings. My solution was to copy the title attribute block to a temporary location, resize the attributes and redefine the block by running a script (scriptpro). Some drawings needed the title line split to next line so I had to move the sheet counter (1 of xx, 2 of xx etc.) which was linked to drawing file name for number with a field/formula.
The diesel expression shown below extracts that number. My problem is I cant figure out how to I can edit this expression to allow for a set not starting at 1. I had used a formula to subtract the difference,but how do you express this to run in a script?
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
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.
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.
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.
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.
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.
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.
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 "
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.
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?).
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?
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.
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?
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.
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
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?
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
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...