Author Topic: version of acad.pgp as lisp?  (Read 5891 times)

0 Members and 1 Guest are viewing this topic.

chthon

  • Guest
version of acad.pgp as lisp?
« on: February 01, 2018, 11:38:38 AM »
hi everyone,
has anyone seen a version of acad.pgp as one-liner lisp?
i believe lisp loads after lower level functioning pgp, and a better way to handle aliases, leaving the original intact
this view i have seen expressed elsewhere, anyway
thanks advanced
chthon

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Re: version of acad.pgp as lisp?
« Reply #1 on: February 01, 2018, 02:52:43 PM »
I've just created a few one-liners. I store them in my acad.lsp file.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:1  () (command ".line")(princ))
  2.  (defun c:2  () (command ".pline")(princ))
  3.  (defun c:3  () (command "._pan")(princ))
  4.  (defun c:4  () (command "._matchprop")(princ))
  5.  (defun c:c  () (command "copy"))
  6.  (defun c:r3 () (command ".arc" pause "e" pause "r"))
  7.  (defun c:ed () (command ".textedit"))
  8.  (defun c:ew () (command ".erase" "w"))
  9.  (defun c:ex () (command ".explode"))
  10.  (defun c:er () (command ".erase" "l" "")(princ))
  11.  (defun c:g  () (command "model")(princ))
  12.  (defun c:q  () (command ".qsave"))
  13.  (defun c:rr () (command ".rotate"))
  14.  (defun c:sc () (command "scale"))
  15.  (defun c:tr () (command ".trim"))
  16.  

HTH
TheSwamp.org  (serving the CAD community since 2003)

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: version of acad.pgp as lisp?
« Reply #2 on: February 01, 2018, 03:13:32 PM »
While it can be done, it overrides any PGP aliases.  Depending on loading of files they may override each other.  Seeing as I don't want to hunt down exactly *which* LSP file any particular (defun c:....) comes from, I don't consider it suitable for most work environments.
If you are going to fly by the seat of your pants, expect friction burns.

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

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: version of acad.pgp as lisp?
« Reply #3 on: February 01, 2018, 04:17:01 PM »
I just put them at the end of my PGP file:

Code: [Select]
qq,    *QuitAlert
RFR,    *DomCALC-REINFORCEMENT
RFC,    *REINFORCEMENTCHECK
SYMS,    *SymbolStretch
bl,    *BreakLine
fra,    *DomREF-FractionDecimalChart
Scales,    *DomREF-ScaleChart
mr,    *mRot
;Z-SHEET LAYOUT NAVIGATION
cover,    *LayoutNavigation-CoverSheet
cov,    *LayoutNavigation-CoverSheet
001,    *LayoutNavigation-CoverSheet
002,       *LayoutNavigation-MasterPMKSheet
101,    *LayoutNavigation-Z101
102,    *LayoutNavigation-Z102
103,    *LayoutNavigation-Z103
104,    *LayoutNavigation-Z104
105,    *LayoutNavigation-Z105
201,    *LayoutNavigation-Z201
202,    *LayoutNavigation-Z202
203,    *LayoutNavigation-Z203
204,    *LayoutNavigation-Z204
205,    *LayoutNavigation-Z205
301,    *LayoutNavigation-Z301
401,    *LayoutNavigation-Z401
501,    *LayoutNavigation-Z501
701,    *LayoutNavigation-Z701
702,    *LayoutNavigation-Z702
et,    *tableexport
TROD,    *ThreadedRod
pnl,    *Panel
TTI,    *TextInsert
WGT,    *TotalWeight-Sheet
GR,    *ProfileGrid
SPLIT,    *SplitTailAnchor
PIN,    *PinAnchor
TIT,    *TitleBar
EM,    *ElevationMarker
DEETS,    *DetailCallOutTag
HD,    *HID
CTL,    *CENTERLINE
CGrid,    *ColumnGridMarker
ltt,    *LayoutTabToggle
sbt,    *StatusBarToggle
PDT,    *PDModeToggle
zez,    *ZoomSaveClose
reb,    *ResetInsertBasePoint
p0,    *PointAtZeroZero
Plate,    *DomPLATE
HSA,    *HeadedStudAnchor
OutRev,    *DomBLOCK-OutsourceTicketRevision
SV,        *DomVIEWPORT_SETVIEWPORTPROFILE
SVW,       *DomVIEWPORT_SETVIEWPORTPROFILEBYWINDOW
SVV,       *DomVIEWPORT_SETVIEWPORTPLAN
SVVW,    *DomVIEWPORT_SetViewPortPlanbyWindow
SVF,       *DomVIEWPORT_SETVIEWPORTFRONT
MPK,    *ViewMPK
PLC,       *DomCALC-PieceLengthCalculator
NT,        *DomTICKET-NEWTICKET
HEX,    *HexBolt
SC4,    *SteelColumn-4x4
BU,    *BURST
D2,    *DIV2PCS
S2,    *StretchM2PtoPoint
DVD,    *DIVIDE
SIGN,    *SIGNLETTERINGDATA
TS,    *TEXTSCR
DG,        *DIMGUIDE
WRE,    *WIRE

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: version of acad.pgp as lisp?
« Reply #4 on: February 01, 2018, 08:59:50 PM »
Bit like others we have 1 lisp file that contains all our library stuff like custom defuns, autoloads plus lots more. it is loaded independently of ACAD.lsp at start up, so if a problem know exactly where to look. Makes upgrades pretty easy when you have multiple machines.     
A man who never made a mistake never made anything

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: version of acad.pgp as lisp?
« Reply #5 on: February 02, 2018, 09:20:38 AM »
One liners I loaded separately from acad.lsp (same method as BIGAL).
Here is a snip from mine.
Code - Auto/Visual Lisp: [Select]
  1. (defun let (binding body)
  2.   ;; quick and dirty command generator.
  3.   ;; allows me to build a ``(defun c:foo () ...'' proced.
  4.   ;; this is only ment to save me some typing now
  5.   ;; and in the future when I want to add to my
  6.   ;; keyboard shortcut list
  7.   ;;
  8.   ;; By: John (7) K
  9.   ;;     10.16.04 12:31:06 PM
  10.   (eval
  11.     (append
  12.       (list 'defun
  13.             (read (strcat "c:" binding))
  14.             nil) body )) )
  15.  
  16.  
  17. (let "pu" '((repeat 5 (command "_.purge" "a" "" "n")) (princ)))
  18. (let "df" '((command "_.matchprop")))
  19. (let "v" '((command "_.copy")))
  20. (let "vv" '((command "_.move")))
  21. (let "g" '((command "_.break")))
  22. (let "b" '((command "_.line")))
  23. (let "bb" '((command "_.pline")))
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: version of acad.pgp as lisp?
« Reply #6 on: February 02, 2018, 01:40:18 PM »
Bit like others we have 1 lisp file that contains all our library stuff like custom defuns, autoloads plus lots more. it is loaded independently of ACAD.lsp at start up, so if a problem know exactly where to look. Makes upgrades pretty easy when you have multiple machines.     

That makes a lot of sense.  Maybe I need to rethink my approach.  I'm a one machine kinda guy!

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: version of acad.pgp as lisp?
« Reply #7 on: February 05, 2018, 10:07:09 AM »
i believe lisp loads after lower level functioning pgp, and a better way to handle aliases, leaving the original intact

Yes, and this is a plus IMO.  We leave the pgp alone, and define shortcuts using Company, Group, and finally User based lisps that load at startup.
If a stock shortcut in the pgp survives this, fine. Otherwise we wanted to overwrite it anyway.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: version of acad.pgp as lisp?
« Reply #8 on: February 05, 2018, 10:35:16 AM »
Which is good IF you've got a very structured environment.  Last week it took a half-day trying to hunt down command "A" (yes, that's it: "A") on something inherited from another office.   :tickedoff:
If you are going to fly by the seat of your pants, expect friction burns.

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

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: version of acad.pgp as lisp?
« Reply #9 on: February 05, 2018, 10:44:02 AM »
Which is good IF you've got a very structured environment.  Last week it took a half-day trying to hunt down command "A" (yes, that's it: "A") on something inherited from another office.   :tickedoff:
:) I've been there a few times. Fun! ...That's one of the reasons I made LiFP (to get organized and clean up a web of mess).
[ http://www.theswamp.org/index.php?topic=37700.0 ]
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

chthon

  • Guest
Re: version of acad.pgp as lisp?
« Reply #10 on: February 09, 2018, 10:05:47 AM »
hi all, & thanks for your responses [i like the code snippet from Se7en]
the reason i am interested thus is that as a contractor, these crucial files are networked and locked, often with ambiguous non-standard aliases, guided by these threads;
http://www.cadtutor.net/forum/archive/index.php/t-17625.html
https://gist.github.com/rddim/9c6125f6d518d1598f04bb5081632cd1
https://www.theswamp.org/index.php?topic=40111.0  ...[cheers].
i came up with this lsp version:  [attached]
time to overcome pgp's alias irregularity / regularity - with this pgp.lsp, usual function library is unaffected, & loaded from acad.lsp / accaddoc.lsp.
h-t-h..
~chthon
« Last Edit: February 09, 2018, 05:00:05 PM by chthon »

ronjonp

  • Needs a day job
  • Posts: 7526
Re: version of acad.pgp as lisp?
« Reply #11 on: February 09, 2018, 01:14:01 PM »
FWIW ..  I think all your defuns need one more closing parenthesis. Attached is a quick harvested stock AutoCAD 2018 vanilla PGP. Have fun!
*edit .. forgot defuns LOL.
« Last Edit: February 09, 2018, 02:31:37 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

chthon

  • Guest
Re: version of acad.pgp as lisp?
« Reply #12 on: February 09, 2018, 04:59:14 PM »
thanks ronjonp! have upload corrected
~chthon

HasanCAD

  • Swamp Rat
  • Posts: 1420
Re: version of acad.pgp as lisp?
« Reply #13 on: February 14, 2018, 02:11:12 AM »
A snap for autorun lisps
Code - Auto/Visual Lisp: [Select]
  1. (LOAD"C:/HaSSaN/AutoCAD/Support/Lisp/trustedpaths.LSP"          )
  2. (LOAD"C:/HaSSaN/AutoCAD/Support/Lisp/Subs.LSP"                  )
  3. (LOAD"C:/HaSSaN/AutoCAD/Support/Lisp/AddSupportPath.LSP"        )

A snap for lisps
Code - Auto/Visual Lisp: [Select]
  1. (defun c:CNTB   ()      (load "C:/HaSSaN/AutoCAD/Support/Lisp/CouNTBlocks.LSP"                  ) (c:CNTB       ) (princ)) ; Block
  2. (defun c:CAT    ()      (load "C:/HaSSaN/AutoCAD/Support/Lisp/CorrectArabicText.LSP"            ) (c:CAT        ) (princ)) ; text
  3. (defun c:CLD    ()      (load "C:/HaSSaN/AutoCAD/Support/Lisp/CoLomnDimension.LSP"              ) (c:CLD        ) (princ)) ; Struc

chthon

  • Guest
Re: version of acad.pgp as lisp?
« Reply #14 on: February 15, 2018, 04:29:25 AM »
hi hasancad,
remember you can always demand load (as in only as / when needed) lsp like this;
Code: [Select]
(AUTOLOAD "C:/HaSSaN/AutoCAD/Support/Lisp/CouNTBlocks.LSP"        '("CNTB"))    ; Block
(AUTOLOAD "C:/HaSSaN/AutoCAD/Support/Lisp/CorrectArabicText.LSP"  '("CAT" ))    ; text
r,
~chthon

chthon

  • Guest
Re: version of acad.pgp as lisp?
« Reply #15 on: February 17, 2018, 10:02:05 PM »
g'day rjp..
wondering what nil does after the defun? as below;
Code: [Select]
;; RJP 2.9.2018 harvest stock PGP and convert to one line lisp list
(defun C:-3DCONFIG nil (command "_.-GRAPHICSCONFIG") (princ))
(defun C:-AR nil (command "_.-ARRAY") (princ))
(defun C:-ARM nil (command "_.-ACTUSERMESSAGE") (princ))
(defun C:-ARS nil (command "_.-ACTSTOP") (princ))
etc - i wasn't able to find any documentation on this, any assistance
appreciated
tia, chthon

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: version of acad.pgp as lisp?
« Reply #16 on: February 18, 2018, 12:09:45 AM »
An empty list is considered nil thus:

(defun c:foo ()  (princ "\nfoo.") (princ))

(defun c:foo nil (princ "\nfoo.") (princ))


are equivalent to the interpreter (but not the eyes).
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

chthon

  • Guest
Re: version of acad.pgp as lisp?
« Reply #17 on: February 21, 2018, 05:03:08 AM »
mp,
makes sense, this is the good thing about code,
thanks,
chthon

ahsattarian

  • Newt
  • Posts: 112
Re: version of acad.pgp as lisp?
« Reply #18 on: February 10, 2021, 05:00:15 AM »
hi all, & thanks for your responses [i like the code snippet from Se7en]
the reason i am interested thus is that as a contractor, these crucial files are networked and locked, often with ambiguous non-standard aliases, guided by these threads;
http://www.cadtutor.net/forum/archive/index.php/t-17625.html
https://gist.github.com/rddim/9c6125f6d518d1598f04bb5081632cd1
https://www.theswamp.org/index.php?topic=40111.0  ...[cheers].
i came up with this lsp version:  [attached]
time to overcome pgp's alias irregularity / regularity - with this pgp.lsp, usual function library is unaffected, & loaded from acad.lsp / accaddoc.lsp.
h-t-h..
~chthon


First and Second Links don't work   !!!!