Jump to content

Recommended Posts

Posted

I have a couple of non-working autolisps due to a computer demise. I seem to have lost some files.  They were also written in the 90s, last updated sometime before 2004 and I currently have autocad 2013.  I don't want to post the whole routines all at once as they are very long.  This is the first routine which is linked to the symbol library.  I have no idea what it does or how to get it to look for the appropriate doslib . it gives "Sm Error:" when I run it.  It used to run on a network so I changed it to a C : startup () and got the same message. After that I am at a loss

 

(defun S::STARTUP ()
	(setvar "cmdecho" 0)

	(setq piddirpre (findfile "pidsetup.lsp"))
	(setq piddir (substr piddirpre 1 (- (strlen piddirpre) 12)))
    (setq pidscale 1.0) ;Scale used for symbols.
    (setq mirrdef "V") ;This is the default mirror orientation used in PIDSYM


	;load DOSLib for either Release 14 or Release 15
	(cond
	  ;if DOSLib is already loaded, return true
	  ((not (null dos_about))
	    T
	  )
	  ;if AutoCAD Release 14, 
	  ((= (atoi (substr (getvar "acadver") 1 2)) 14)
	    (arxload "doslib14")
    	)
	  ((= (atoi (substr (getvar "acadver") 1 2)) 15)
	   (arxload "doslib2k")
	   )
	  ((= (atoi (substr (getvar "acadver") 1 2)) 16)
	   (arxload "doslib2004")
	   )
    )
	(setvar "cmdecho" 1)
	(princ "\n")
	(princ "\n")
	(princ)
)
    
(defun sm-error (msg)
	(setvar "cmdecho" 0)
	(if oldattdia (setvar "attdia" oldattdia))
	(if oldattreq (command "attreq" oldattreq))
	(if oldangbase (setvar "angbase" oldangbase))
  	(if oldlay (setvar "clayer" oldlay))
	(if oldosmode (setvar "osmode" oldosmode))
	(princ "Sm Error: ")
	(setq *error* olderror)
	(setvar "cmdecho" 1)
	(princ)
)

(setq *error* sm-error)

(load "pidsym")

(defun dtr (a)
(* pi (/ a 180.0))
)

(defun rtd (a)
(/ (* a 180.0) pi)
)

 

I mucked about with autolisp in back 2005/6 but I have forgotten most of it and what I did dealt with counting and labelling blocks

Posted

I am no expert but lets work it out....

 

(defun dtr.... and (defun rtd... sound familiar, degrees to radians and radians to degrees, and look OK so lets discount them as a problem

(setq *error* sm-error) runs the LISP sm-error of there is an error happening, lets look through that.... a load of reset setvar to old.... looks OK and then a princ command "SM Error" which is what you are seeing. So if there is an error, the (setq *error* spots this and runs sm-error, ending with you seeing "SM Error" on the screen... and if you see that then the error function is working OK I reckon. Lets ignore that bit then

 

Leaving you with (defun S::Startup.

 

Hmmm, if we remove each line with a ; and then delete them one by one that should give the problem

 

You can try this before going further?

 

next step is to put back in the easy bits that shouldn't casue a problem, put back the cmdecho lines and setq without any calculations. Plotscale MirrorDef, comdecho, princ all work OK, now try the conds... all good?

 

doing it step by step I reckon you are left with the the first 2 lines of code

(setq piddirpre (findfile "pidsetup.lsp"))
(setq piddir (substr piddirpre 1 (- (strlen piddirpre) 12)))

 

piddir needs piddirpre to work. piddirpre... find file "pldsetup.lsp', oh, that could be a problem, where is this file? When the old computer died did it get moved to the new ones trusted files location? Does it still exist even? If it is another location, have you made it searcheable by default by CAD - something you might have done years ago and forgotten about

 

If you can locate the file and it isn't found by CAD, try hard coding in the file path where it exists, remembering to add a double // instead of a single / for text file paths in between "

 

 

If you are having a problem with another file, could the cause be the same, not finding the file it is looking for, could be they didn't get copied, could be you need to set a trusted file location to be where they are saved.

 

 

 

  • Like 1
Posted

 

Hi Steven P

Thanks for your ideas

I have all the lisp routines saved and pathed according to the instructions given by the original author of the code

I've been copying the code line by line into a new document and testing as I go.

 

I got  "; error: malformed list on input" for these

 

Is there an easier way to ensure the DOSLib is loaded?

;load DOSLib for either Release 14 or Release 15
	(cond
	  ;if DOSLib is already loaded, return true
	  ((not (null dos_about))
	    T
	  )


 

((= (atoi (substr (getvar "acadver") 1 2)) 15)
	   (arxload "doslib2k")
	   )

 

Posted

If your setting a bunch of values like this.

(defun sm-error (msg)
	(setvar "cmdecho" 0)
	(if oldattdia (setvar "attdia" oldattdia))
	(if oldattreq (command "attreq" oldattreq))
	(if oldangbase (setvar "angbase" oldangbase))
  	(if oldlay (setvar "clayer" oldlay))
	(if oldosmode (setvar "osmode" oldosmode))
	(princ "Sm Error: ")
	(setq *error* olderror)
	(setvar "cmdecho" 1)
	(princ)
)

 

have this at the start of the main lisp. first two are needed to capture the values. the third line you can set  new values all at once but isn't needed.

(setq vars '(attdia attreq angbase clayer osmode)   ;list of variables
      vals  (mapcar 'getvar vars)                   ;store old values in a list called vals
)
(mapcar 'setvar vars '(# # # "layername" #)) ;set new values

 

So to reset all values back you only need this line.

(mapcar 'setvar vars vals) ;sets all values back to before
  • Like 2
Posted

@mhupp , this post made me want to study writing lisps, because the syntax and structure of the code is so accessible.

I know that writing code is logical, puzzle solving, but seeing it like this just drives that fact home.   :thumbsup:  :beer:

 

  • Like 1
Posted

nice, and if you get stuck or need advice you know where to come.

  • Like 1
  • Thanks 1
Posted

Mhupp Started using the setvars method today on some new code, THANKS. Easier than foreach.

  • Like 3
Posted

the setvars and setq don't seem to be what's giving me the problem with this one

Posted

The easiest way of checking doslib is to remove and replace the functions generally with VL functions. But you have to know what your doing.

 

The load on start up does not need s::startup any more as that is what it replaces. So you could just use Appload and add the lisp file to the Startup suite.

 

What does (load "pidsym") do is that where error occurs just type it on command line and see.

 

Also (setq piddir (substr piddirpre 1 (- (strlen piddirpre) 12))) as we have no idea of what the findfile has found or not. Findfile has a few rules and looks in support paths so maybe you have a incorrect support path. The file is there but others are not. 

 

 

Posted

This is the pdsym lisp. it's rather long and way over my head.  

right now I'm just trying to figure out how to make sure the doslib for 2013 gets loaded properly so the rest of his lisp routines work. (Especially this one as it saves hundreds of mouse-clicks each day and I would like to avoid another bought of tendonitis) I can't seem to get it to load through the appload dialogue

PIDSYM.lsp

Posted

Found this    "This section below is where the chosen symbol is inserted."

 

Is it something like this, select a symbol.

 

image.png.fe8901c31243c60644844c2a2b63d4ca.png

 

The code refers to slide images, a lot of sld files, and it is looking for pidsym.dcl, newsym.dcl, yesno,dcl do you have those also ?

 

I think what is best is describe what the program does then we can get a better idea of what is missing.

Posted
On 8/8/2022 at 11:25 PM, patmf said:

I have a couple of non-working autolisps written in the 90s, last updated sometime before 2004 and I currently have autocad 2013.

 

	;load DOSLib for either Release 14 or Release 15
	(cond
	  ;if DOSLib is already loaded, return true
	  ((not (null dos_about))
	    T
	  )
	  ;if AutoCAD Release 14, 
	  ((= (atoi (substr (getvar "acadver") 1 2)) 14)
	    (arxload "doslib14")
    	)
	  ((= (atoi (substr (getvar "acadver") 1 2)) 15)
	   (arxload "doslib2k")
	   )
	  ((= (atoi (substr (getvar "acadver") 1 2)) 16)
	   (arxload "doslib2004")
	   )
    )

 

DOSLib Version 9.0.3 Supports AutoCAD 2013 thru 2021 and would be the version you need to load for it to work in AutoCAD 2013.

  • Like 1
Posted

I have the right version of Doslib now but now I get

Pydsetup failed to set values aborting

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...