AutoCAD .NET :: How Lisp Function Interpret Lists Passed In
Jun 20, 2012
I had thought this was fixed in 2012, but it seems that lists passed in to a lispfunction, get interpreted as if the first items was a dotted pair code.I first noticed this on a tool that takes three integers as an rgb color.
On some values, it shows null for the args in.On some, it reinterprets as if I am passing in a point.
If I pass in '(1 2 3), I get (5009, (1,2,3)) in .net so that is a 3d point.
Note that this alone is a bug, as its a list of three integers, not a point.
If I pass in '(10 20 30), I get (10, (20, 30, 0)) in .net
If I pass in '(228 27 185), I get null in .net
If there is going to be any interpretation going on, it should be because I sent in a dotted pair list. How Autodesk wants us to pass in lists so they come in as just a list of values sent in. URL....
How can I condense the 'history tree' that lists all the function? Like, putting multiple sketches into one folder and then being able to expand it to display all of them?
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.
This morning the shop brought back a set of drawings and requested that I provide a cut list for the fab department. Our drawings consist of an assembly drawing and materials list on the first page with several individual parts on each of the following pages. I am looking at including a column in the ML for the operation ( laser, saw, shear) and sorting the list by it. However when I do this the Item Numbers on the list are all confused. If a person were to look at a balloon on a drawing and then attempt to find it in the list it would be difficult and time waster.
The questions.
1. Is there a way to renumber the item list after sorting the material?
2. If I place an assembly view off the edge of the sheet for each of the following sheets and then place a materials list on each sheet, is it possible to create a plugin that would find which parts are on the sheet and hide all the other parts on the list? I have just started going through the "my first plugin" tutorial and this sounds like a place where it should be useful but I don't know which tags I need to look for.
I am trying to write a piece of a program that gets the layers from a drawing, and checks each one against a list of layers. If the layer is not a member of any of the lists it asks the user which layer list to add it to. This is what I have so far, but every time I try to run it I get a bad argument error.
Depending on the user's choice the layer gets written to an external file where the layer lists get their layers from in the beginning and then adds the layer to the relevant list to use later in the program.
Someday the light bulb is going off and I will understand mapcar and lambda. However.....I have a program that reads an excel file sheets. Sometimes the sheet only has 1 column, sometimes 2 or more.
I need to convert the saved values from the sheet to a list with the text spaced evenly. Unfortunately the text lengths vary. I would like a subroutine to pass the list to and return a list of strings with text aligned with padded spaces allowing for the longest text in each column. I am using the new list in a dialog box with fixed_width_font=true (so columns align).
I am writing a program to grab a bunch of layers from a list, check a drawing to see if the layers are on the list, and if not save to an external file. I have the second part of the program done, but I can't get the first part to work.
I am trying to open a file read the contents and save it to a list.
Here is the code I have so far, but it doesn't even get into the foreach statement.
i have a simple fence line type with "x"s....if i draw the line straight up or to the right it looks perfect. but if i draw it anywhere to the left then the Xs are off centered.
[URL]The example near the bottom shows an unfolded sheet metal part being exported to DXF and there is an option to change the output format in that example. But I don't know how to get to it from a IPT file that is a standard part.
I started with a IPT file and exported as a DWG.Then I created a Layout with the view that I wanted in DXF format and used Save As, selected DFX and I got three DXF files, Model, Layout_1 and Layout_2.
However, I have no way of knowing what format was used for the DXF output. I want AutoCAD version R12. how to interpret the hyroglyphs in the help pages?
Example:
[URL]
Export DXF Options
That page is not useful. It seems to have been written for an earlier version of Inventor. I am still running 2013.
Maybe this is because I have Inventer and I do not have inventor Pro. Is that the problem here? Is this ONLY possible with inventor Pro?
i'm trying to create a LispFunction in vb.net in visual studio 2010 (tried both .net 3.5 and .net 4.0) and it's like autocad is just ignoring them. is there a setting or something to disable .net LispFunctions from being loaded? CommandMethods work just fine, and i'm not seeing any errors. in fact i'm using the most basic of functions, just returning the arguments. and nothing. Any diagnostic or something to determine what's the matter?
<LispFunction("HelloWorld")>Public Function HelloWorld(args As ResultBuffer) As ResultBuffer Return argsEnd Function does nothing, when i setq a variable on it, it's just nil.
I am currently in the process of re-writing my VBA in .net.In VBA I successfully used AcadDocument_BeginClose which called lisp functions.It would be nice to have all code in the same environment I need to transition my changes.
Therefore I need to call lisp from .net.My function works well when run withing the cad files session but does not appear to call the lisp when called after the BeginDocumentClose.
Is it possible to call a lisp function after the BeginDocumentClose event?
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)) )
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.
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:
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:
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)))
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?
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.
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
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?
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))