AutoCAD Visual LISP / AutoLISP :: Creating Array Using Split Function?
Jan 10, 2013
In asp I'd write:
arrFileName = Split(DrawingName, "_")
JobNumber = arrFileName(0)
DrawingTitle = arrFileName(1)
SheetNumber = arrFileName(2)
I'd like to do the same thing in lsp. I don't want to be limited to three fields so the split function is perfect.Is there an equivalent?
View 3 Replies
ADVERTISEMENT
Oct 25, 2013
This seems absolutly silly.
(setq p1 (getpoint))
(setq p2 (getpoint))
(setq Dist (distance p1 p2))
Why does this not work?
I'm trying to build a command to replace AutoCAD's "DI" command, to give distance and delta x, y, and z values in decimal and imperial, and keep the angles in XY plane and out of XY plane.
View 9 Replies
View Related
Mar 12, 2012
I would like to do an array polar for 4 items and union with the command "union" all of them automatically.. how can i do that in a lisp ?
View 9 Replies
View Related
May 7, 2013
simple example code how can i set my lisp function to radio button ?
i found simple dcl - lisp codes , there is possibility for calling simple cad commands , but this is different about call lisp with buttons
which code i have to change and how for set my lisp on radio buttons ..
here is the sample codes ...
SAMPLE1 : dialog { label = "Sample Dialog Box Routine - Part 1"; : column { : boxed_column { : button { key = "but1"; label = "Button 1";
[Code].....
View 3 Replies
View Related
Nov 27, 2012
I want to define en expiration date in registry, after that date the some LISP programs does not allow to run. I think that suitable commands are SetEnv and GetEnv.
define a ExpDt variable that contains Expiry Date as a string. And add some statements inside of the LISP program to call this variable and check it with today's date.
I should define once time in autocad:
(setenv "expdt" "130101"); YYMMDD date for validation period (2013.01.01)
and check this every time that a lisp program should be execeute:
(getenv "expdt") ; if today's date(with YYMMDD format) ">" expdt then lisp program doen not allow to run and should be halted.
for e.g. on 2013.02.28: "130228" > "130101" ==> so the lisp function should be halted and will not work!
(without any alert or message)
a sample list function: (how can implement on this lisp function?)
(defun c:3()
(setq w t)
(while w
(setq a (getpoint "
pick point:"))
(setq p1 (list (- (car a) 0.5)(- (cadr a) 0.5)))
(setq p2 (list (+(car a) 0.5)(+(cadr a) 0.5)))
(command "erase" "w" p1 p2 "")
(command "INSERT" "*3" a "" "" "0")
)
(if (= a nil)(setq w nil))
)
View 9 Replies
View Related
May 15, 2013
In the foreach function can you use math like (foreach pt1 (add 1) so that foreach one you pick it adds one the next one will be named pt2 then pt3 and so on.
View 6 Replies
View Related
Dec 29, 2011
I would like a small menu to pop up near the cursor like the middle mouse button menu, but based on some other function key or quick key shortcut.
View 2 Replies
View Related
Aug 17, 2012
The error below has appeared randomly when AutoCAD 2011 is started. There was not an error of this sort, but it suddenly appeared and some of the LISP routines will no longer work.
*Invalid attempt to access
a compiled function definition. You may want to define it using defun-q:
#<SUBR @000000003f5fda98 S:: STARTUP>
View 1 Replies
View Related
Jun 3, 2013
How to make a lisp command that will select all objects in the drawing?
View 3 Replies
View Related
Mar 13, 2012
I open the drawing without loading the function, when I modify an object with the reactors appears the following error message:
function definition: NAMEFUNCTION
You can avoid this annoying message without removing the persistent reactors?
View 3 Replies
View Related
Jun 25, 2013
I prepared a code to calculate number of days between two date.
I want to know how can I define negligible arguments for my lisp routins. It means if I omitted the arguments, lisp code can handle it without any errors ("; error: too few arguments")
In this case, my program defined as: (TotalDays 1st_date 2nd_date)
(TotalDays 1978 03 21 2013 06 25)
and I want to have flexibility: if I use this routine as (TotalDays 1978 03 21), the program should substitute today's date with second date.
I know if I put "nil" instead of date for 2nd_date, It will not be an error, because:
(if (and y2 m2 d2) (setq n2 (GetJDN y2 m2 d2))(setq n2 (fix (getvar "DATE"))))
but that's not my favourite!, how can I omitted 2nd_date completely? as (TotalDays 1978 03 21)
Here is my lisp
;|How to use:(TotalDays 1978 03 21 2013 06 25)|;;;;;By Abbas Aqdam(defun TotalDays ( y1 m1 d1 y2 m2 d2 / n1 n2)(setq n1 (GetJDN y1 m1 d1))(if (and y2 m2 d2) (setq n2 (GetJDN y2 m2 d2))(setq n2 (fix (getvar "DATE"))))(abs(- n1 n2)));;;;Leap years are included;;;;By Abbas Aqdam(defun GetJDN ( year month day / a y m J)(setq a (/(- 14 Month) 12))(setq y (-(+ year 4800) a))(setq m (-(+ Month (* 12 a)) 3))(setq J (-(+ day (/(+(* 153 m) 2)5) (* 365 y) (/ y 4) (/ y 400)) (/ y 100) 32045)))
View 9 Replies
View Related
Jan 10, 2012
I D/L a lisp file (setvars.lsp) that purports to give a list of system variables that match a short string entered in a dialog box.
Unfortunately, an error arises that says 'error : no function definition: STRNUM'
I've looked at the code and can't tell what the writer was hoping to achieve.
The specific section is as follows:
(if F1
(progn
(setq RL (read-line F1))
(while RL
(if (and (wcmatch (strcase RL) (strcase (strcat "*" DESCR1 "*")))
(wcmatch (strcase RL) (strcase (strcat "*" DESCR2 "*")))
[Code] .........
There is no other mention of STRNUM in the whole of the lisp.
There is an accompanying setvars.dat, wherein apparently, the writer compiled a data file of all the system variables in AutoCAD2008, each variable being followed by an '=' and then a description of the variable.
If necessary I can post the whole lisp and dat file, but was hoping to discover the intention from the above extract and therfore where I might work out an alternative to this line.
Looking to turn a string to a real? If so, why are there two 'arguments' following the 'function' STRNUM?
View 9 Replies
View Related
Jan 23, 2012
I was able to find/update a LISP program that returns the dynamic block to its original state, overriding the anonymous name and make the actual block name the effective name. I am in the process of manipulating the LISP program so I can select multiple blocks rather than one at a time.
(defun CYMEFFEC ()(vl-load-com) (setq obj (vlax-ename->vla-object (car (entsel "Select blocks: ")))) (vlax-put obj 'Name (vlax-get obj 'Effectivename)))
View 3 Replies
View Related
Jan 28, 2012
I would like to insert a block in a specific layout (eg. "LAYOUT13") using the function vla-insertblock
I have already searched the web and this newsgroup but have not found the solution.
View 3 Replies
View Related
Nov 15, 2013
I have a simple lisp function to add a scale axis to a drawing by calling a script, renamed the drawing by appending "withScale" to the file name, and then closing the file. I placed a call to the function in the acad.lsp file in the startup suite. The idea was to batch process all files by simply opening them. Upon open the startup acad.lsp file runs, which calls my lisp function, which in turn calls the scale script. It should then execute the renaming, saving, and closing commands. The problem is that it is calling the script fine and renaming the file, but it does not save the changes before closing. Here is the lisp function
(defun saveScale(); (command "-purge" "all" "" "n")(if (findfile "C:/Users/Russell/Desktop/TreeFiles/Automation/Scale&Key.scr")(command "_script" "C:/Users/Russell/Desktop/TreeFiles/Automation/Scale&Key.scr")); end if (command "_.zoom" "e") (command "_saveas" "2013" (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "withScale.dwg")) (command "close") ) (saveScale)
Apparently you cannont run any lisp commands after calling a script, however the renaming still follows through.
I've attached the script file as well. (I couldn't attach .scr format so you may need to rename it).
View 9 Replies
View Related
Sep 16, 2013
I have a list function that asks for the user to pick points when it is run. It looks something like this (foo arg1 arg2) When invoked it asks the user to pick points and press enter when done It.
Instead of getting the points from the user i want to pass it a list of pre-defined points. The code cannot be changed so I must use it as is.Is this possible, if so how can it be done?
View 9 Replies
View Related
Mar 13, 2012
I've got a subroutine that gets the centroid of a closed polygon (lwpoly). It appears to fail if the polygon has any zero length line segments. I've added a trap that catches the error and "highlights" the offending polygon, but it stops there and does not return to the main function that called the subroutine. Is there a way to get back to the main function from the trap?
Here's the subroutine (original function by _gile (Autodesk LISP Forum 9-18-2006):
(defun return-centroid (lwpoly space / obj Region Centroid)
(setq *error* trap1)
(setq obj (vlax-ename->vla-object lwpoly))
(setq Region (vlax-invoke space 'addRegion (list obj)))
(setq Centroid (trans (vlax-get (car Region) 'Centroid) 1 0))
(vla-delete (car Region))
[code]....
View 2 Replies
View Related
Oct 28, 2011
I am looking for a function to print out the entire entity list of the selected entity...
so... walking down through the entity data... print out what it finds... any time it encounters an entity name... then do an entget and print that out too.
View 8 Replies
View Related
Dec 16, 2011
This probably isn't the correct discussion group but not sure where else to post this.
My sales department wants to be able to create drawings based on entries in selected in their Excel qouting tool. Basically, they want to configure a product in the field, and be able to show the customer the drawing with TrueView. (They don't have AutoCAD installed).
I would think the best I can do, is manipulate a .dxf file based on their selections but that may get very complicated.
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 11, 2013
I am attempting to create a export command for our surveyors that deletes all there point layers and seal layer, then audits and saves the file before opening the etransmit command.
Below is what I currently have.I know there is a better way to do this, but it is above my programing skill right now.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SURVey export(defun C:SRVY () (command "-laydel" ; Delete Survey data "Name" "F0" "Name" "F1" "Name" "F2" "Name" "F3" "Name" "F4" "Name" "F5" "Name" "F6" "Name" "F7" "Name" "F8" "Name" "F9" "Name" "F10" "Name" "F11" "Name" "F99" "Name" "SHEET-SEAL" ENTER "YES" ) (command ".audit" "y") ; Audits file (command "_qsave") ; Save changes (command "-etransmit" "Choose Setup" "ACAD2010" "Create transmittal package" ) (princ))
AutoCAD Civil 3D 2012 (Primary), 2011 by contract.
Dell Percision T3500: MS Windows 7 64-bit SP1; Intel Xeon CPU W3505 @ 2.53GHz, 12.00 GB RAM, NVIDIA Quadro 600
View 1 Replies
View Related
Nov 4, 2012
i'm newbie in customizing tools in autocad especially in creating hatch pattern. i understand that to create new hatch pattern is by adding a new hatch pattern in acad.pat file with specific angle.
my question is is it posibble to create a hatch pattern that can use specific angle follows the object shape?
This is what autocad can do by default this is what i'm trying to create
View 7 Replies
View Related
Nov 12, 2013
I am creating a line using entmake, but I need the start and end point to be variable that was already defined ex.
(entmake '((0 . "LINE")(8 . "FIELD") (10 . line_insert) (11 line_end)))
Command: !line_insert
(29.2813 20.5 0.0)
Command: !line_end
(29.2813 18.5 0.0)
The error I get is
; error: bad DXF group: (10 LINE_INSERT)
What do I do to make it recognize this variable?
View 1 Replies
View Related
Oct 24, 2012
I've been fighting with building a formula in a block utilizing a field from another block. I have a support steel member that once placed, will be lengthened. I need a distance from center of the pipe to the top of concrete. I created a block with a field referencing the insertion point (center of pipe) it works fine giving me this elevation. I also have another block that is the datum node. I have several fields in this block, and it is located at the bottom of the support steel plate. I am trying to create a field that takes the center of pipe elevation and subtracts the datum node elevation to get a distance. I created the formula referencing the COP elevation field and the elevation of the datum node. The information shows properly where I am building the formula, when I click evaluate, the Preview gives me ##### and when I create the datum node block that is also the output I get. I can't figure out why it won't give me the difference between the two elevation fields. I don't know what I can do differently to have that information in the datum node.
View 1 Replies
View Related
Sep 20, 2013
I have some code that starts a new drawing with a specific template from a lisp routine
(defun ghd:load_newdwg (template / ae-acad-object newdwg)
(setq ae-acad-object (vlax-get-acad-object))
(setq newdwg (vla-add (vla-get-documents ae-acad-object) template))
(vla-put-activedocument ae-acad-object newdwg)
)
The template location and file is stored in variable clienttemplate (and is not the standard template path set under options). All works okay except if I close the new drawing, when I return to the previous drawing that was current when the new drawing was created (i.e. the drawing that the routine was run from). I get the following error:
Command: ; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Unknown exception occurred
; warning: unwind skipped on unknown exception
I assume this has something to do with the original routine not closing/finishing before switching to the new drawing. This is the last line of the routine:
(cond ((= startnewdwg 1) (ghd:load_newdwg clienttemplate)))
View 3 Replies
View Related
Nov 22, 2011
I am able in lisp to create a command prompt selection menu, easy (see code below).However what I want is for the lisp to be ready to undertake an action UNLESS I select an option.
An example is the offset command wich has a function ready to roll (namely the specify offset distance) "OR" I can interrupt the "specify offset distance" and enter one of the sub options (in the case of offset Through/ Erase/Layer).
My code attempts to offset also, UNLESS the user wishes to specify a distance.
(DEFUN C:loadoffset ();CREATING MENU FOR SUB COMMANDS [GETIT] [GOTIT]...(setq choose (getstring "
Select an option... [1=GET DIST] [2=GOTDIST]: "))(if (or (equal choose "1"))(GETIT))(if (or (equal choose "2"))(GOTIT));TERMINATING SELECTION MENU...)(defun getit ( gotit )(setq MYDIST (getdist "
SELECT A DISTANCE: "))(gotit))(defun gotit ()(command "_offset" MYDIST pause pause"exit"))
View 9 Replies
View Related
May 6, 2007
I would like to be able to check if an Annotation Scale already exists and if it doesn't I would like to create it using the SCALELISTEDIT command and then set it to be the curent scale. I then plan to invoke the MLEADER command.
I do not want to have to rely on adding every possible scale in the list beforehand as my program would fall appart when a user decides to set an unusual scale I haven't thought of adding to the list.
See my initial start of the program.
(defun C:MLD ()
(command "cannoscale" "1:55") ;STOPS HERE WHEN 1:55 DOES NOT EXIST
(setq IfAnnoScaleExists (getvar "CANNOSCALE"))
(command "-scalelistedit" "add" "1:55" "1:55" "e")
)
View 5 Replies
View Related
Jan 4, 2012
I have a series of boxes or polygones that I would like the program to find the 1/2 distance and create two seperate polylines from the one object.
Example:
I have a square with pt1,pt2, pt3 and pt4 respectively. After I have ran the program it would create a diagonal from pt1 to pt3 and join the rest of the lines now to create the one polyline. Also it would do the same to create another exact polygonal shape for the other half. Thus creating two shapes of equal value from one.
View 9 Replies
View Related
Dec 2, 2011
cannot find a way to create a pdf and saving it into a desktop. Basically, in the -plot command, there should be an option to allow it to save to C:documents and settings"username"desktopfilename.pdf"
See the command line used:
(COMMAND "-PLOT" "Y" "" "DWG to PDF.pc3" "30 x 42" "Inches" "Landscape" "No" "Extents" "1=1" "CENTER" "Yes" "Fullsize.ctb" "yes" "No" "No" "No" "C:\Documents and Settings\Username\Desktop\Filename.pdf" "N" "Y")
The objective is to allow the lisp to plug in whichever username and automatically creating a pdf based on the filename.
View 3 Replies
View Related
Aug 21, 2012
What I need is a trigger saved within a drawing dwg file which if found will launch a lisp to run if the trigger is not present in the dwg the lisp will not run.
If memory serves me correctly the trigger was managed by creating a unique table search item saved in the actual dwg file. A start-up lisp would then search for it and if found it would run the lisp if not it would simply continue as if nothing happened.
View 6 Replies
View Related
Apr 17, 2012
I have hundreds of drawings I want to run through scriptpro with a script calling 3 different lisp routines. I have the 3 lisps working independantly but can't figure out how to get them to all run in one script.
Two of the Lisps are for redefining the title block in 2 different types of drawings that have different title blocks. The last lisp locks all viewports in all windows. I'll attach the 3 lisps I'm trying to merge in the script. I am not very versed in scripts and lisps so I'm guessing at least 2 of these lisps could be merged into a single lisp...
Here is what I have for the script file contents (which doesn't work):
(load "redefine100")
(load "redefine102")
(load "vlocker")
View 1 Replies
View Related