Author Topic: Migrating from AutoCAD 2010 to 2013 lisp question  (Read 7612 times)

0 Members and 1 Guest are viewing this topic.

KNester

  • Guest
Migrating from AutoCAD 2010 to 2013 lisp question
« on: November 08, 2012, 11:37:18 AM »
Forgive me if I am posting incorrectly- I am new to the process and am also new to the AutoCAD/Autolisp programming world.

I have been tasked to unify our AutoCAD deployments for use at multiple locations and on different networks.  I'm in the process of updating our lisp files to allow for this, however the last person (before my time) that was tasked to update AutoCAD 2005 to AutoCAD 2010 didn't update the lisp files to 2010.  My question (the first of many I'm sure) is if there are any changes within the lisp files that I need to make in order for them to 1. allow them to be loaded into the existing 2010 format and 2. If changes need to be made for them to work in AutoCAD Mechanical 2013.  I know with .Net programming, there are binary compatibility issues between 2010 and 2013, but since lisp has been around for decades (and hasn't changed too much during that time period), I didn't know if changes need to be made there as well.  For instance, changing load to vl-load-com as needed to be done from 2000 to 2005.   Any help or recommendations would be greatly appreciated!

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #1 on: November 08, 2012, 11:56:25 AM »
That's the beauty of lisp ... it's fairly version independent :). The problems I've seen are when command calls (command "pedit" "" "") are used within a lisp routine and then the prompts for those commands change from version to version.

Welcome to TheSwamp :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #2 on: November 08, 2012, 12:15:53 PM »
Welcome to the Swamp  8-)

As ronjonp states, AutoLISP is reasonably version independent, the prompt order of some commands may have changed, but this will only affect your programs if your programs make use of calls to standard AutoCAD commands.

For instance, changing load to vl-load-com as needed to be done from 2000 to 2005.

FYI: Note that load and vl-load-com are two different functions entirely, performing very different actions - vl-load-com is not a replacement for load in later versions of AutoCAD.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #3 on: November 08, 2012, 01:34:51 PM »
Generically programmed LISP is portable.  But, depending on how the originals were built, there may be version- or location-dependant calls and references.  Some examples are:

- hard-coded path references to support files
- calling support files with extensions that are no longer used (e.g. both MNU/S/C and CUI files have been superceded by CUIx files)
- calling path references with assumptions to drive mapping
- calling printers with assumptions to naming, and/or plot styles with assumptions to name/CTB/STB
- local language characters
- (command ...) calls without globalization underscores
- assumption of third-party or in-house tools such as DOSLib which may not be available at all locations
- COM references to objects such as Word or Excel, which may be dependant on the version of those programs
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

KNester

  • Guest
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #4 on: November 08, 2012, 02:38:35 PM »
Thanks everyone!  Greatly appreciate all of your input.  Ther may be more questions to come, but it's a great start so far!

matthewj

  • Newt
  • Posts: 42
  • Vanilla
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #5 on: November 08, 2012, 07:23:05 PM »
I've been doing this same thing at work recently.  This is what I use to test for various autocad releases in my code to work around these issues. http://www.theswamp.org/index.php?topic=43092.msg483087#msg483087.  If a command or feature varies or is missing in one version to another, I'll usually test for the acad version within a conditional or if statement to run the correct code.

For example:

Code: [Select]
;offset edge to create slot
(defun c:wjslot (/  temp rec1 rec2 version )

(if (acad-ver '>= "2011")
(progn
(command "offsetedge" pause "d" ".01" pause "")
(setq temp (getdist "Select half extrusion height:"))
(setq rec1 (entlast))
(command "copy" rec1 "" "0,0,0" "0,0,0" "")
(setq rec2 (entlast))
(command "extrude" rec1 "" (strcat "+" (rtos temp 2 7)))
(setq rec1 (entlast))
(command "extrude" rec2 "" (strcat "-" (rtos temp 2 7)))
(setq rec2 (entlast))
(command "union" rec1 rec2 "")

(if (tblsearch "LAYER" ".Sketch")
(command ".chprop" "_p" "" "_la" ".Sketch" "")
) ;if

) ;progn

(alert "This command requires AutoCAD 2011 or higher to operate.")

) ;if

(princ)
) ;defun[code=cadlisp-7]
[/code]
Cheers!

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #6 on: November 09, 2012, 03:01:54 AM »
This is one of the very nice things about lisp (and other interpreted languages). You need not "re-compile" anything. The compiling happens on the fly while the code runs. Even if you've "compiled" your lisp into FAS / VLX files, those are bit-coded files and not binary executables - they're still interpreted just optimized. Thus you need not even re-"compile" them.
 
With DotNet it's a bit of a borderline case. There are basically 2 reasons why DN needs recomiling: (1) the DotNet 4.0 has become a requirement from ADesk's side for 2013, where 3.0 could be used in 2007 through 2009 upt to 2012, and 3.5 for 2010-12. This usually happens every 3rd release. (2) But ... due to ADesk also changing the API itself, since 2013 it needs to link to other files and there are some changes to the source itself. Thus 2013 simply does not work with a DLL compiled for an earlier acad.
 
About what to do to ensure as few required "upgrades" to your lisps:
Actually, if you run into a situation where the prompts for commands have changed ... it's 90% of the time a situation of the prompt's shortcut keys (those shown as capitals) being changed. So for me I always use the full word of the prompt instead of just the one or two characters. E.g. in your code I'd change the CHPROP line as follows:
Code - Auto/Visual Lisp: [Select]
  1. (command "._ChProp" "_Previous" "" "_Layer" ".Sketch" "")
That way even after ADesk changes the shortcuts in a future version you won't have to update a single thing (at least in that line). It's extremely seldom that they'd change the entire name itself. Also note I've added the underscore to the command call as well ... thus making it language independent for the command name also.
 
If you stick with this principal and follow a generic method for the pathing and such (as described by dgorsman) then I've never come across anything I have to change in old lisps to have them run in newer acads. And that is since 2000 all the way through to 2013. The only thing I remember having to change was when they introduced MDI (mutiple document interface - introduced in R12 or somewhere in the mid 90's) ... but that simply required me to rename the ACAD.LSP file to ACADDOC.LSP and all worked perfectly again.
 
The other way round may be an issue. If you've written a lisp using the new (since 2012) properties functions, then you cannot expect that same lisp to run inside 2010/11. So you'd need to stick with lisps using only the functionality available in the oldest acad throughout all your distributions. Similar applies to 3rd party apps like dgorsman's already said.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #7 on: November 09, 2012, 05:42:44 AM »
Very informative Irné, nice one.  :-)

johnratliff

  • Guest
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #8 on: September 26, 2013, 05:15:12 PM »
I'm just a rookie, and need a little help in migrating a lisp.

I've got thie older CADALYST 3dtext.lsp file that worked in 2011 but not in 2013. First thing I noticed was it wouldn't load the command so I moved it to a search path. Then I ran the VLIDE debug and it stops here:

Quote
(vla-put-colorindex vla_truecolor (atoi color))


Code: [Select]
  -snip-
      ((member acad_ver '("2010" "2011" "2012")) ;AutoCAD v18 (2010, 2011, 2012)
      (setq vla_truecolor (vla-getinterfaceobject (vlax-get-acad-object) "AutoCAD.AcCmColor.18"))
    )
  )
  (cond
    ((and (= 'INT (type color))
          (and (<= 0 color)
               (>= 256 color)))
      (vla-put-colorindex vla_truecolor color)
    )
    ((or (= color "0")
         (and (= 'STR (type color))
              (> 0 (atoi color))))
      (vla-put-colorindex vla_truecolor (atoi color))
    )
    ((and (= 'STR (type color))
          (= 0 (atoi color)))
      (vla-put-colorindex vla_truecolor (eval (read (strcat "ac" color))))
    )
    ((listp color)
      (vla-setrgb vla_truecolor (car color)(cadr color)(caddr color))
    )
  )
  (vla-put-TrueColor object vla_truecolor)
)
-snip-

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #9 on: September 27, 2013, 05:38:30 AM »
If you can be interest, these are some things that can change from one version to another.
I did a quick cut and paste, if you need more information we are here.

;---------------------------------------------------------------------------------
(if (> (atof (getvar "ACADVER")) 16.1)
  (command "_.IMAGEFRAME" 0)
  (command "_.IMAGEFRAME" "_OFF")
)
;---------------------------------------------------------------------------------
(setq #pDbMod (> (atof (getvar "ACADVER")) 16.0 ))
(or #pDbMod (acad-push-dbmod))
;---------------------------------------------------------------------------------
(if (> (atof (getvar "ACADVER")) 16.1)
  (command "_.PURGE" "_ALL" "*" "_N" "_.PURGE" "_REGAPPS" "*" "_N")
  (command "_.PURGE" "_ALL" "*" "_N")
)
;---------------------------------------------------------------------------------
( (> (atof (getvar "ACADVER")) 16.1)
  (if (setq MnuPat (findfile "user.cui"))
    (progn (command "_.CUIUNLOAD" "ASSO") (vl-file-delete MnuPat))             
    (if (or (setq MnuPat (findfile "user.cuix")) (setq MnuPat (findfile "user.cui")))
;---------------------------------------------------------------------------------
(if (> (atof (getvar "ACADVER")) 16.1) (command "_.CUILOAD" "USER.MNU") (command "_.MENULOAD" "USER"))


Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #10 on: September 27, 2013, 05:47:34 AM »
If you play with dimensions:

; Version for 2004/2005/2006 with acdb16.dll of 2006
;
;       DSTYLE_DIM_LINETYPE > LINETYPE per la linea di quota
;("ACAD_DSTYLE_DIM_LINETYPE"              (1070 . 380) (1005 . "1A30")) il gruppo 1005 determina l'Handle di LTYPE table
;("ACAD_DSTYLE_DIM_EXT1_LINETYPE"         (1070 . 381) (1005 . "1A30")) il gruppo 1005 determina l'Handle di LTYPE table
;("ACAD_DSTYLE_DIM_EXT2_LINETYPE"         (1070 . 382) (1005 . "1A42")) il gruppo 1005 determina l'Handle di LTYPE table



; Version for >= 2007
;
;("ACAD_DSTYLE_DIMEXT_LENGTH"             (1070 . 378) (1040 . 10.0)  ) 1040 determina la lunghezza DIMEXT
; DIMFXL > Imposta la lunghezza totale delle linee di estensione, dalla linea di quota fino all'origine di quota.
; Dxf = 49
;
;("ACAD_DSTYLE_DIMARC_LENGTH_SYMBOL"      (1070 . 379) (1070 . 0)     ) 1070 determina la posizione del simbolo arco
;                                                          0 = prima del testo - 1 = sopra il testo - 2 = nessuno     
; DIMARCSYM > Controlla la visualizzazione del simbolo arco in una quota di lunghezza dell'arco.
;
;("ACAD_DSTYLE_DIM_LINETYPE"              (1070 . 380) (1005 . "1A30")) 1005 determina l'Handle di LTYPE table
; DIMLTYPE > Imposta il tipo di linea della linea di quota. Il valore č DALAYER, DABLOCCO oppure il nome di un tipo di linea.
;
;("ACAD_DSTYLE_DIM_EXT1_LINETYPE"         (1070 . 381) (1005 . "1A30")) 1005 determina l'Handle di LTYPE table
; DIMLTEX1 > Imposta il tipo di linea della prima linea di estensione. Il valore č DALAYER, DABLOCCO oppure il nome di un tipo di linea.
; Dxf = 346
;
;("ACAD_DSTYLE_DIM_EXT2_LINETYPE"         (1070 . 382) (1005 . "1A42")) 1005 determina l'Handle di LTYPE table
; DIMLTEX2 > Imposta il tipo di linea della seconda linea di estensione.
; Dxf = 347
;
;("ACAD_DSTYLE_DIMEXT_ENABLED"            (1070 . 383) (1070 . 1)     ) 1070 determina DIMEXT_ENABLED on/off
; DIMFXLON > Controlla se le linee di estensione vengono impostate su una lunghezza fissa.
; Dxf = 290
;
;("ACAD_DSTYLE_DIMJOGGED_JOGANGLE_SYMBOL" (1070 . 384) (1040 . 1.5708)) 1040
; DIMJOGANG > Determina l'angolo del segmento trasversale della linea di quota in una quota ridotta di raggio.
;
;("ACAD_DSTYLE_DIMFLIPARROW_SYMBOL"       (1070 . 385) (1070 . 0)     ) 1070 determina ?
;
;("ACAD_DSTYLE_DIMFLIPARROW_WHICH_SYMBOL" (1070 . 386) (1070 . 3)     ) 1070 =1 inverte 1a freccia - =2 >2a - =3 >entrambe
;
;("ACAD_DSTYLE_DIMTEXT_FILL" (1070 . 376) (1070 . 2) (1070 . 377) (1004 . "1800000001000000040000C3000000000000000000000000"))))
; DIMTFILL > Controlla lo sfondo del testo di quota.
;
; DIMTFILLCLR > Imposta il colore per lo sfondo del testo nelle quote.
;


LibertyOne

  • Guest
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #11 on: October 01, 2013, 07:47:53 AM »
The only thing I remember having to change was when they introduced MDI (mutiple document interface - introduced in R12 or somewhere in the mid 90's) ... but that simply required me to rename the ACAD.LSP file to ACADDOC.LSP and all worked perfectly again.

I'm most certain it was ACAD 2000. R14 you had to start multiple sessions if you wanted two or more files open. That ACADDOC.LSP stuff was 2000.   :mrgreen:

curmudgeon

  • Newt
  • Posts: 194
Re: Migrating from AutoCAD 2010 to 2013 lisp question
« Reply #12 on: October 02, 2013, 09:00:42 AM »
ONE THING I have noticed is that they had added a (90 . 0) amongst the vertex group codes for a LWPOLYLINE.
If a routine was based on nth instead of assoc, it will count wrong.
I have found no purpose for the 90 group code in any discussion - but leaving it at zero has worked in all my stuff.
 :ugly:
Never express yourself more clearly than you are able to think.