Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

old lisp routine won't work in adt2010

25 REPLIES 25
Reply
Message 1 of 26
rhots
1349 Views, 25 Replies

old lisp routine won't work in adt2010

Hi folks, this routine worked forever till 2010. It seem spretty simple but I am pretty weak in lisp.

I t seems to get hung up when actually creating the fillets. My guess is it no longer recognizes the way the code is written in the areas I circled. The command prompt shows an error

"*Invalid selection*
Expects a point or
Window/Last/Crossing/BOX/Fence/WPolygon/CPolygon/uNdo/Polyline/Radius/Trim

 

Thanks for any help you can offer.

 

PS you might notice an extra fillet command in the beginning. this is because 2010 also was not recognizing the fillet command below that line

(command "_.fillet" "")
  (command "_.fillet" "R" RADIN)   

 

Thanks again,

Rick

 

25 REPLIES 25
Message 21 of 26
rhots
in reply to: Kent1Cooper

I think I had the correct veins....this is making my brain bleed !!! LOL

Message 22 of 26
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
....I think there are ways to do this without those, and without requiring the User to select the Lines and the side to which to offset them -- maybe I'll look at that later.

....


So I thought about and experimented a little with that, and in the process got past the missing functions but found it wasn't liking the INT Osnap call somehow, but rather than fight with that, I figured there would be a way to do the whole thing also without using either Fillet or any kind of object snap call at all, nor any (vlax-...) functions.  The following calculates the intersection points and uses Change on the Lines instead of Fillet.  [That is equivalent to 0-radius Fillet, so it works here, but it would be a lot more complicated to do it that way for the radiused corner in the other routine.]

 

I used regular Insert for the vanes Block, because I wasn't sure what all the arguments are in your specialty insertion function, but I assume you can make that adjustment.  And I made a different Block definition [attached], with a one-unit length extending in the 0-degree direction from its insertion point, to greatly simplify the insertion part of the process.

 

This does require that both ducts be the same width for it to work as expected, as I think yours would [though this could be altered to allow different widths, if that ever happens], but I believe unlike yours, it doesn't require them to be perpendicular.  It figures out all it needs to without caring at what point any Line is picked, so it goes directly to saving just the entity names from the (entsel) functions.  It seems to work in minimal testing.

 

;; This routine will make a non-radiused duct intersection from four
;; Lines representing two ducts, and insert a turning-vanes Block.

;;;  Could be made more sophisticated:
;;;    Typical error handler;
;;;    Save-and-reset OSMODE/CMDECHO/ORTHOMODE;
;;;    Could check whether selected objects are Lines, and on unlocked
;;;      Layers, and whether the two lines of each duct are parallel, and
;;;      whether the duct widths are the same, and [if desired] whether
;;;      the two ducts are perpendicular;
;;;    Could draw on a designated Layer, or on the Layer of one of the
;;;      selected Lines, and change back afterwards.

(defun C:DUCTELB (/ INA OUTA INB OUTB ends intin intout angA)
  (setvar 'osmode 0); off
  (setvar 'orthomode 0); off
  (setq
    INA (car (entsel "\nPick inside Line of duct A: "))
    OUTA (car (entsel "\nPick outside Line of duct A: "))
    INB (car (entsel "\nPick inside Line of duct B: "))
    OUTB (car (entsel "\nPick outside Line of duct B: "))
    ends ; list of all Lines' start points and all end points [one list variable in place of eight point variables]
      (append
        (mapcar '(lambda (x) (cdr (assoc 10 (entget x)))) (list INA OUTA INB OUTB))
        (mapcar '(lambda (x) (cdr (assoc 11 (entget x)))) (list INA OUTA INB OUTB))
      ); append
    intin (inters (nth 0 ends) (nth 4 ends) (nth 2 ends) (nth 6 ends) nil); INTersection INside
    intout (inters (nth 1 ends) (nth 5 ends) (nth 3 ends) (nth 7 ends) nil); INTersection OUTside
  ); setq
  (command
    "_.change" INA INB "" intin ; in place of Fillet
    "_.change" OUTA OUTB "" intout
    "_.line"
      (polar
        intin
        (setq angA (angle intin (inters (nth 0 ends) (nth 4 ends) (nth 3 ends) (nth 7 ends) nil)))
          ; [above is angle from inside intersection to virtual intersection of INA and OUTB; use of
          ; (inters) avoids need to figure out which end of INA is closer to intin to get correct angle]
        -4 ; negative to go in opposite direction from that virtual intersection
      ); polar
      (inters (getvar 'lastpoint) (polar (getvar 'lastpoint) (+ angA (/ pi 2)) 1) (nth 1 ends) (nth 5 ends) nil)
        ; [above is point perpendicular from there to INA, without use of Osnap]
      "" ; finish Line
    "_.mirror" "_last" "" intin intout "_no" ; [this works right only if duct widths are equal]
    "_.insert" "VANES" "_scale" (distance intin intout) intin intout
  ); command
); defun

 [EDIT -- I put the code in a Code window to avoid the possible emoticon; but now I notice it does some word wrapping (I thought it wasn't supposed to do that, and it doesn't as seen in the editing window), so fix that if you copy it out.]

Kent Cooper, AIA
Message 23 of 26
rhots
in reply to: Kent1Cooper

way way way beyond me, you are the man, thanks very much!!!!

Message 24 of 26
Anonymous
in reply to: rhots

Is there any way to preserve your OSNAP settings when using either of these two routines? They get nuked whenever these routines are invoked.

Message 25 of 26
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

Is there any way to preserve your OSNAP settings when using either of these two routines? They get nuked whenever these routines are invoked.


Yes -- there are multitudinous routines on this forum that do that.  [The OP had them just turned off, so I left it that way since other issues were more pertinent, though I don't typically do that.]  It involves saving the value of the OSMODE System Variable at the beginning, before setting it to 0, and then resetting it at the end.  You can also reset it in an error handler to ensure it gets reset in case some error occurs or the User cancels the whole operation with Escape or something.

 

Search the Discussion Group for just about anything that includes:

 

(getvar 'osmode)

or

(getvar "osmode")

 

[they're equivalent, and not case-sensitive], and you'll find ways it is typically done.  The same can be done with ORTHOMODE that this thread's routines also turn off, or any other System Variable(s) you might want to set to a particular value for purposes of the routine at hand.

Kent Cooper, AIA
Message 26 of 26
Anonymous
in reply to: Kent1Cooper

Thanks for the quick response Kent, and for also taking it easy on the 'forum noob.' When in doubt, search first, then ask. I'll dig into OSMODE...

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost