Author Topic: A long time ago in a lisp file far far away...  (Read 4196 times)

0 Members and 1 Guest are viewing this topic.

deegeecees

  • Guest
A long time ago in a lisp file far far away...
« on: July 25, 2005, 08:26:59 AM »
I once wrote a routine that would keep a pline command running until the user typed an "E" for END or "S" for the selection of a circle to run to the center point of. I have since lost this routine as it was some 10 years ago, can anyone point me in the right direction? I'm thinking it was something to do with "initget".

Aaaaand...

How to explode a block and capture all the exploded entities for layer manipulation.

daron

  • Guest
A long time ago in a lisp file far far away...
« Reply #1 on: July 25, 2005, 08:44:35 AM »
a) dunno... where you put it.


b) (setq block (vla-explode (object to explode)))

Those vla-methods will return a list of your exploded objects. You can collect them the usual way. Beautiful tools they are.

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
A long time ago in a lisp file far far away...
« Reply #2 on: July 25, 2005, 08:59:59 AM »
Quote from: daron
(setq block (vla-explode (object to explode)))
Attention, doesn't work anymore with NUS block (Bug since A2k4)
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

daron

  • Guest
A long time ago in a lisp file far far away...
« Reply #3 on: July 25, 2005, 09:02:27 AM »
No way. Well, don't explode NUS's. Man that sucks. Thanks Jurg. We'll have to keep that in mind.

deegeecees

  • Guest
A long time ago in a lisp file far far away...
« Reply #4 on: July 25, 2005, 09:06:06 AM »
Quote from: daron
a) dunno... where you put it.



I left it with the company I was working for... oops.

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
A long time ago in a lisp file far far away...
« Reply #5 on: July 25, 2005, 09:07:11 AM »
Quote from: daron
Man that sucks.
and it sucks also that we (and others) report this bug to Autodesk and they haven't fix it until now. A2k6 owns still the same rubbish.
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
A long time ago in a lisp file far far away...
« Reply #6 on: July 25, 2005, 09:07:20 AM »
I borrowed this from somewhere.
Think Michael Puckett may be the author.

Code: [Select]
;;============================================================
;;  Function to get the absolute last entity in the database
;;  Returns nil is drawing is completely empty
(defun ALE_LastEnt ( / EntNam OutVal)
  (and
    (setq OutVal (entlast)); if there is an entity in drawing
    (while (setq EntNam (entnext OutVal))
      (setq OutVal EntNam)
    )
  )
  OutVal
)
;;============================================================
;;  Function to get new items after EntNam in the database
(defun ALE_Ss-After (EntNam / EntNxt SelSet)
  (cond
    ( (not EntNam) (ssget "_X") ); dwg was empty
    ( (setq EntNxt (entnext EntNam)); get new items
      (setq SelSet (ssadd EntNxt))
      (while (setq EntNxt (entnext EntNxt))
        (if (entget EntNxt) (ssadd EntNxt SelSet))
      )
      SelSet
    )
  )
)
;=========================================================

;;=====================================================================
;;===================  Code to get New objects ========================
;;=====================================================================
(setq elast (ALE_LastEnt)); get last entity in database
(setq newbies (ssadd)) ; create an empty selection set
;;
;; Do your array or paste command
;;
(setq newbies (ALE_Ss-After elast))
;; newbies is a selection set of all items created by your command.
;;=====================================================================
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
A long time ago in a lisp file far far away...
« Reply #7 on: July 25, 2005, 09:12:54 AM »
Can't take credit for that one Alan. I believe the prefix "ALE_" belongs to my friend Marc'Antonio Alessi. If I recall correctly (was long ago), we penned similar functions in a thread on the desk's news server but his was prettier. But thank you nonetheless.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
A long time ago in a lisp file far far away...
« Reply #8 on: July 25, 2005, 09:32:35 AM »
Good morning MP :)


deegeecees
Here is a quickie, BUT it doesn't catch the user pressing ENTER
For that you would need to add some more code. :)

Code: [Select]
(defun getp (/ p1 p2 cmd loop)
  (setq loop t)
  (setq p1 (getpoint "\nPick start of pline."))
  (command "pline" p1)

  (while (and loop
              (not (initget "S E"))
              (setq p2 (getpoint p1 "\nPick piont or enter [E S]. "))
         )
    (cond
      ((= (type p2) 'list)
       (command p2)
       (setq p1 p2)
      )
      (t
       (setq loop nil
             cmd  p2
       )
      )
    )
  )
  (command) ; end pline
  cmd
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

deegeecees

  • Guest
A long time ago in a lisp file far far away...
« Reply #9 on: July 25, 2005, 10:18:18 AM »
Thanks CAB! Thats what I was working towards, and I am very pressed for time.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
A long time ago in a lisp file far far away...
« Reply #10 on: July 25, 2005, 10:41:50 AM »
You're welcome.
Say if you only want to prevent an exit from the Enter Key just add a 1 to the intiget

Code: [Select]
(not (initget 1 "S E"))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

deegeecees

  • Guest
A long time ago in a lisp file far far away...
« Reply #11 on: July 25, 2005, 10:45:47 AM »
The "E" is to end the command, and the "S" is for STUBUP as in conduit runs. I'll play around with the code a bit till I get it to work the way I want...    ...press "S" and then prompt for circle selection, use polar, get radii and end pline at that point.