Author Topic: Splines inside lisp routines  (Read 2881 times)

0 Members and 1 Guest are viewing this topic.

KewlToyZ

  • Guest
Splines inside lisp routines
« on: August 28, 2007, 06:24:56 PM »
I'm trying to code through a routine where I need a spline added.
Whenever I add a spline the command exits from the spline command without coming back to the routine.
How do I construct the point set and close pts inside the routine instead of spline for this?
A seperate defun for myspline?
Code: [Select]
(defun thermo (/ rotpt en ed)
  (command "explode" "l" "")
  (setq tstat (entlast))
  (setq rotpt (cdr (assoc 10 (entget tstat))))
  (command "rotate" "l" "" rotpt "0")
  (setq en (entlast))
  (while
    (setq en (entnext en))
     (setq ed (entget en))
     (if
       (equal (cdr (assoc 0 (entget en))) "ATTRIB")
(progn
  (setq ed ; rotate attribute to 0
(subst (cons 50 0)
(assoc 50 ed)
ed
)
  )
  (entmod ed)
  (entupd en)
)
     )
    ;(setvar "cmdecho" 0)
    (setvar "Expert" 3)
(command "linetype" "Load" "SML-DASH" "acad.lin" "")
(setvar "Expert" 0)
(command "layer" "m" "M-CONT-WIRE" "l" "SML-DASH" "M-CONT-WIRE" "c" 7 "M-CONT-WIRE" "LW"  0.35 "M-CONT-WIRE" "" ) 
    (setvar "autosnap" 13)
    (setvar "osmode" 191)
    ;(setvar "cmdecho" 1)
    (command "spline") ;pause pause
    )   
 )
« Last Edit: August 28, 2007, 06:26:31 PM by KewlToyZ »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Splines inside lisp routines
« Reply #1 on: August 28, 2007, 06:35:11 PM »
Perhaps try something like ..
Code: [Select]
        (command "SPLINE")
        (WHILE (WCMATCH (GETVAR "CMDNAMES") "*SPLINE*") (COMMAND pause))
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

KewlToyZ

  • Guest
Re: Splines inside lisp routines
« Reply #2 on: August 28, 2007, 07:20:12 PM »
Super slick Kerry!
Except entering the last close point brings up the spline command again?
I still end up on the layer the spline was drawn on instead of returning back to the original layer before the routine began.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Splines inside lisp routines
« Reply #3 on: August 28, 2007, 07:34:05 PM »
Manually enter 'C' 'Enter'
Then Manually 'Enter'

What happens ?

What are you using to return to the layer.
Post the code you're using without the other stuff .. ie with just the relevant code to change layer, draw spline, restore layer ..
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

KewlToyZ

  • Guest
Re: Splines inside lisp routines
« Reply #4 on: August 28, 2007, 08:07:18 PM »
I found a way around it:
Code: [Select]
; Thermostat brought into smartinsert routine .......
;=======================================================================================
(defun tstatrot (/ rotpt en ed); *error* save_sys_vars restore_sys_vars
  (command "explode" "l" "")
  (setq tstat (entlast))
  (setq rotpt (cdr (assoc 10 (entget tstat))))
  (command "rotate" "l" "" rotpt "0")

  (setq en (entlast))
  (while
    (setq en (entnext en))
     (setq ed (entget en))
     (if
       (equal (cdr (assoc 0 (entget en))) "ATTRIB")
(progn
 (setq ed ; rotate attribute to 0
(subst (cons 50 0)
(assoc 50 ed)
ed
)
 )
 (entmod ed)
 (entupd en)
)
     )
    ;(command "cmdecho" 0)
    ;(lrs "M-CONT-WIRE")
    ;(command "cmdecho" 1)
    (setvar "cmdecho" 0)
    (setvar "Expert" 3)
(command "linetype" "Load" "SML-DASH" "kta.lin" "")
(setvar "Expert" 0)
(command "layer" "m" "M-CONT-WIRE" "l" "SML-DASH" "M-CONT-WIRE" "c" 7 "M-CONT-WIRE" "LW"  0.35 "M-CONT-WIRE" "" )  
    (setvar "autosnap" 13)
    (setvar "osmode" 191)
    (setvar "cmdecho" 1)
    ;(command "spline")
    ;(IF (WCMATCH (GETVAR "CMDNAMES") "*SPLINE*") (COMMAND pause)
    )
    (command "spline")
    (WHILE (WCMATCH (GETVAR "CMDNAMES") "*SPLINE*") (COMMAND pause)
    )
    (*error* "") ; restore variables
    (command "osmode" usersnaps); -----------------------Return User Osmode Settings
   (command "clayer" userlayer); -----------------------Return User Layer Settings
(princ "\n Thermostat Osnaps & Layer Returned. (tstatrot)..")
   (princ)
 )
 (princ "\nSmart Insert Loaded!")

The routine was too large for posting the code so I figured I could post them.
The command from a button:
(smartinsert 0 19 "clayer" "mechanical/kta_mdv005")(tstatrot)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Splines inside lisp routines
« Reply #5 on: August 28, 2007, 08:40:06 PM »
You may want to look at the 300 occurances of this :

(= (strcase new_lay) (strcase "S-COLM-E"))

seems a little extravagant ... just set a new variable for the uppercase string and try something like ;
(= new_lay-UC) "S-COLM-E") ..


added: .. and it may be more economical to test if the layer exists in the layer table first .. unless it's your intention to reset the color and linetype each time ??

« Last Edit: August 28, 2007, 08:51:58 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

KewlToyZ

  • Guest
Re: Splines inside lisp routines
« Reply #6 on: August 28, 2007, 08:56:27 PM »
Thanks for the advice, it is my next project.
I found some other bugs I missed in the smartinsert:
Code: [Select]
(defun tstatrot (/ rotpt en ed); *error* save_sys_vars restore_sys_vars
  (command "explode" "l" )
  (setq tstat (entlast))
  (setq rotpt (cdr (assoc 10 (entget tstat))))
  (command "rotate" "l" "" rotpt "0")

  (setq en (entlast))
  (while
    (setq en (entnext en))
     (setq ed (entget en))
     (if
       (equal (cdr (assoc 0 (entget en))) "ATTRIB")
(progn
  (setq ed ; rotate attribute to 0
(subst (cons 50 0)
(assoc 50 ed)
ed
)
  )
  (entmod ed)
  (entupd en)
)
     )
    (command "cmdecho" 0)
    (lrs "M-CONT-WIRE")
    (command "cmdecho" 1)
    (setvar "autosnap" 13)
    (setvar "osmode" 191)
    )
    (setvar "osmode" 191)
    (setvar "autosnap" 13)
    (command "spline")
    (WHILE (WCMATCH (GETVAR "CMDNAMES") "*SPLINE*") (COMMAND pause)
    )
  (*error* "") ; restore variables
  (command "osmode" usersnaps); -----------------------Return User Osmode Settings
  (command "clayer" userlayer); -----------------------Return User Layer Settings
  (princ "\n Thermostat Osnaps & Layer Returned. (tstatrot)..")
  (princ)
 )
The layerset is meant to force layers back to standard settings in case someone tries to deviate from the company standards.
I have a committee of engineers at war about layers and default settings right now lol!
I'll definately take a look at cleaning up the mess it is though soon!

KewlToyZ

  • Guest
Re: Splines inside lisp routines
« Reply #7 on: August 29, 2007, 11:41:22 AM »
I am curious, What can I do to allow for xref objects and blocks to be possible as selection objects for inserting objects with this? Is there just to much hidden for a selection to recognize a line in an xref?

KewlToyZ

  • Guest
Re: Splines inside lisp routines
« Reply #8 on: August 29, 2007, 01:31:22 PM »
I thought it was a failure in my getpoint but it would appear to be in the xrefCordTrans.....
XREF AEC walls I think are causing the failure.

KewlToyZ

  • Guest
Re: Splines inside lisp routines
« Reply #9 on: August 29, 2007, 02:06:17 PM »
Reading the XREF objects seems to have really bizarre effects on entity selection when they are AEC objects in the reference drawing. Some read fine while others cause adverse results even if they are the same object type on the same layer. AutoCAD 2008 is in the command and has the right layer available during the insert but slips the object back onto the 0 layer simply because of the object selected. I can select multiple points for the object to be inserted on and some result properly while others spit out the insert to the 0 layer or call it an invalid 2D/3D point. the items all exist as 2D objects at 0 elevation as well.
« Last Edit: August 29, 2007, 02:07:25 PM by KewlToyZ »

KewlToyZ

  • Guest
Re: Splines inside lisp routines
« Reply #10 on: August 29, 2007, 05:28:40 PM »
After reading the post on SuperFlatten in here I am beginning to think that adding depth to this would not be very profitable using the MEP interface. Maybe a dumbed down version could get me through this better.