AutoCAD Visual LISP / AutoLISP :: Return To Calling Function After Trapping Error In Subroutine

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


ADVERTISEMENT

AutoCAD Visual LISP / AutoLISP :: Commands Not Finishing After Calling Script Within Function

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

AutoCAD Visual LISP / AutoLISP :: Compiled Function Definition Error

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

AutoCAD Visual LISP / AutoLISP :: STRNUM Error - No Function Definition

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

AutoCAD Visual LISP / AutoLISP :: Calling Mleaders With Mtext

Oct 17, 2007

I'm finding Mleaders with Mtext don't seem to play well with command calls. All works fine until one tries to enter the mleader text. Before testing this, be sure your mleader style is set to use mtext. I recommend starting the leader with the arrow first.

Compare this mleader's text entry behavior in this basic lisp command call:(command "_.acad_dim.mleader") with the following routine that relies on an open ended command prompt (useful if you want to add more commands after calling the mleader command):

(defun c:mlx (/ cc_echo)
(prompt "
Example showing mleader mtext misbehaving")
(setq cc_echo (getvar "cmdecho"))
(setvar "cmdecho" 1)
(command "_.acad_dim.mleader")
[code]...

With qleaders, the leader and text are separate entities.

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Calling Image Tile Menu From Routine?

Nov 18, 2011

What is the code to call an image tile menu from a lisp command. I currently have a menu item that calls this image tile menu: $I=TYPSMBL1 $I=* but I want to have a keyboard shortcut as well "SL".

View 1 Replies View Related

AutoCAD Visual LISP / AutoLISP :: No Function Definition With Distance Function

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

AutoCAD Visual LISP / AutoLISP :: Return Name Of Different Folders?

May 15, 2013

The following gives me the first folder string, with no back-slashes, that the drawing exists in.

(setq FirstFolder
 ((lambda (/ tmpDir tmpPos)
 (substr
 (setq tmpDir (getvar "dwgprefix"))
 (+ 2 (setq tmpPos (vl-string-search "\" tmpDir)))
 (- (vl-string-search "\" tmpDir (1+ tmpPos)) (1+ tmpPos))))))

Is there a way to find the name of the second folder?

Is there a way to find the name of the third folder?

The string length of the characters for each of the first, second, third (and so on) folders are different, which means I can't count character using the "substr" function.

View 8 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Return Last Command

Jun 27, 2013

Trying to diable the spacebar = (return last command) function!

commandlinehide does te job in the working interface, but a space in scriptmode (in the filename e.g.) still repeats last command!

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: GetBoundingBox Return Bad Results For Z Value

Aug 5, 2013

The lisp routine displays point values of a boundry (window) of an object using the vla_getBoundingBox.

The concept of the routine is to select any object and return two Point window value.

This routine works, but I noticed the Z point is changing depending on the object type drawn in 2d space elevation 0.0.

Test: Open a new drawing.  Set the snap value to 1.0 just to make is easy to see values.

Draw three objects: A horizonal line, A Rectangle and Arc.

Load the gbb.lsp and run it, gbb

Select all three objects and notice the results.

It appears that objects the have an curve change the Z value (very little), but Z should be zero.

Try it with a polyline and then PEdit and FIT and re-check the Z value.

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Return Coordinates Of LWPOLYLINE

Oct 21, 2013

I recently wrote a lisp routine that was supposed to get the 4 coordinates of a rectangle (LWPolyline).  It worked fine in *MY* tests.  But when someone else ran it, the routine operated as though the order of the points had been rearranged.

How can I get the points AND the order in which they belong?

Here's a sketch to show you what I mean.  As part of my troubleshooting, I had a lisp routine draw a new pline using the points gathered by my first routine.  The result of that on the left.  On the right is the result of that when someone else runs the two routines.

Here's the code I used to get the points.

(defun getplinepointlist(ename)
(setq ent(entget ename))
(setq ptlist (list))
(while (setq pt(cdr(assoc 10 ent)))
[code].......   

View 6 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Cancel Return Value Of REPEAT Command

Jan 10, 2013

I use the Repeat command with an index, and when it exits, it writes the last index.

I cannot move it to a new line,nor cancel it.

If i insert a (princ "") inside the loop it moves it to a new line, but also all  the outputs of the loop get extra line spaces

View 1 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Return Entity Name Largest Polyline Of A Selection Set

Oct 8, 2013

I need to return the entity name of the largest (longest closed) polyline in a selection set. At this point I have no trouble creating the selection set and even getting the area of the boundingbox, which is not the most accurate way to find the true size, but it's a start. The part that has me stumped is: if I iterate through the selection set, then how can I compare one to the other when I have access to the current entity. I've been staring at examples of lambdas but it seems to me that iterating through the selection set is going about it wrong in the first place. 

Below is my current code with a remaining issue. I can return the largest area of the polylines (no good for more than two entities in selection set), but I do not know how to return the entity name:
 
(IF (> (SETQ SS (SSGET "x" '((0 . "*POLYLINE") (8 . "POOL") (-4 . "<OR") (62 . 5) (62 . 256) (-4 . "OR>")))) 1 ) (PROGN (SETQ a (1- a) ent (CDR (CAR (SSNAME ss a))) en2 (CDR (CAR (SSNAME ss (1- a)))) ar1 (APPLY '* (LIST (LAMBDA (ent) (VLAX-INVOKE-METHOD (VLAX-ENAME->VLA-OBJECT ent) 'getboundingbox 'minpt 'maxpt) (SETQ pt1 [code]......

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Return A List Of Strings Of Layout Tabs In Drawing

Mar 6, 2013

(layoutlist) ... returns a list of strings of the layout tabs in the drawing.I've used this ages... Isn't it a core lisp function, or is it coming from express tools or somewhere else?

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: ANGTOS Return Accurate Result For Number If Decimal Places Requested

Jan 5, 2012

I work with ANGTOS and ANGTOF quite a bit.  I'm working with latitude and longitude conversions in MAP 3D for an application where accuracy is top priority.  Most of the time ANGTOS (and RTOS, for that matter) return an accurate result for the number if decimal places requested, but then I run into a situation like this:

Command:
(angtos (angtof "120.0") 1 16)
"119d59'59.999999999949""

I got it to return properly by specifying only 13 decimal places, but the result makes conversion between coordinate systems inaccurate.

View 1 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Set Function To Radio Buttons

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

AutoCAD Visual LISP / AutoLISP :: Expire Date For A Function

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

AutoCAD Visual LISP / AutoLISP :: Math In Foreach Function

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

AutoCAD Visual LISP / AutoLISP :: Create A Pop Up Menu Triggered By A Function Key?

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

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 View Related

AutoCAD Visual LISP / AutoLISP :: Function For SELECTED ALL Object In Drawing?

Jun 3, 2013

How to make a lisp command that will select all objects in the drawing?

View 3 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Object Reactor And Load Function LSP

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

AutoCAD Visual LISP / AutoLISP :: How To Define A Function With Negligible Arguments

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

AutoCAD Visual LISP / AutoLISP :: Upgrade Function To Grab Multiple Blocks?

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

AutoCAD Visual LISP / AutoLISP :: Insert Block In A Specific Layout Using Function

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

AutoCAD Visual LISP / AutoLISP :: Passing A List Of Points To Function Instead Of User Input

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

AutoCAD Visual LISP / AutoLISP :: Function To Print Out Entire List Of Selected Entity?

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

AutoCAD .NET :: Build LISP Function To Return Selection Set?

Aug 29, 2011

Is there any way to build a LISP function in .Net to return a selection set? 

View 1 Replies View Related

CorelDRAW X4 :: Failed To Launch Server Application / Error When Calling Edit Bitmap - Function

Jun 5, 2008

URL.... "Failed to launch server application" when trying to edit a bitmap out of CorelDraw, only later saw that specific post was for X3.  I have the same trouble, only with X4.

To recap my problem: When calling the "edit bitmap" function in X4 - I receive this message: "Failed to launch server application".  Paint opens, closes, opens, closes and then the message pops up. 

I tested several files, different bitmaps, different dpi's, new files with newly converted bitmaps (filled rectangle to bitmap).  To no avail. 

View 12 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Error In While Command

May 22, 2013

We have a lisp routine that I co-authored ages ago and then haven't done much programming in about 7 years.  I seem to have forgotten much of my language skills.  This portion of the lisp routine was running fine in autocad 2005 which is what the computer had on it, and it doesn't run on autocad 2010. 

I've narrowed it down to the while statement which is why you see it commented out, but that portion is necessary.   My main question is was there a change in the language specifically the while statement between 2005 and 2010? 
 
; GET LINES OVER 10" AND THROW OUT (if (= (cdr(assoc 0 outerinfo)) "LWPOLYLINE") (progn (setq remlenouter 0.0) (setq numseg (cdr(assoc 90 outerinfo))) (setq edd (member(assoc 10 outerinfo) outerinfo)) (setq n1 0) ;(while (< n1 (- (* numseg 4) 4)) ;(setq dist (distance (cdr(nth n1 edd)) (cdr(nth (+ n1 4) edd)))) ;(if (>= dist edmmax) (setq remlenouter (+ remlenouter dist))) ;(setq n1 (+ n1 4)) ;) ; end while (setq dist (distance (cdr(nth n1 edd)) (cdr(nth 0 edd)))) (if (>= dist edmmax) (setq remlenouter (+ remlenouter dist))) ) ; end progn ) ; END IF

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Semantic Error In DCL

Apr 16, 2013

So i have almost 30 installs and my custom programs are working in all but this new install. Now when i pick on the tool palette that runs the program, i get a message shown in the attached png, then when i pick "OK" i get "Unable to load dialog box."

I've searched these hallowed halls but all the messages seem to point to 2002 versions of ACAD Map and i'm running plain AutoACAD (that came with Product Design Suite, aka Inventor.)

View 2 Replies View Related







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