Author Topic: my routine stopped working  (Read 1813 times)

0 Members and 1 Guest are viewing this topic.

HelpLispinSeattle

  • Guest
my routine stopped working
« on: July 31, 2013, 10:33:54 AM »
Hello,

We had this routine for about 15 years now. For some reason it stop working
in the latest versions of autocad. It's supposed to create a duct mitered elbow.
If I put an "alert" the routine works. If I take out the "alert", it does not work.

Can somebody please fix/rewrite this for us.

I was trying to "insert" an image. So I'll just attached the image.

Thanks in advance.



Code: [Select]
(defun c:test ( / Lay CLay FRad L1 L1m Ln ent Lay L2 L2e L2m  L3 L3m L4 L4m int1 int2 ang1 ang2 )
(if (not LipDistance) (setq LipDistance (* (getvar "Dimscale") 0.0625)))
(setq CLay (getvar"cLayer"))
(setq FRad (getvar "filletrad"))
(setvar "cmdecho" 0)
(setvar "orthomode" 0)
(princ "\nSelect the lines couter-clockwise. ")
(setvar "osmode" 512)
(setq L1 (getpoint "\nEnter OUTSIDE of branch duct<Nearest>: "))
(setq Ln (ssget L1))
(setq ent (entget (ssname ln 0)))
(setq Lay (cdr (assoc 8 ent)))
(setvar "OSMODE" 128)
(setq L2 (getpoint L1 "\nEnter INSIDE of branch duct<Perpendicular>: "))
(setvar "OSMODE" 512)

(setq L3 (getpoint "\nEnter INSIDE of main duct<Nearest>: "))
(setvar "OSMODE" 128)
(setq L4 (getpoint L3 "\nEnter Opposite side of main duct<Perpendicular>: "))
(setvar "OSMODE" 0)
(setq L1 (osnap L1 "nea"))
(setq L1m (osnap L1 "midp"))
(setq L2 (osnap L2 "nea"))
(setq L2m (osnap L2 "midp"))
(setq L2e (osnap L2 "endp"))
(setq L3 (osnap L3 "nea"))
(setq L3m (osnap L3 "midp"))
(setq L4 (osnap L4 "nea"))
(setq L4m (osnap L4 "midp"))

(alert "1")

(setq int1 (inters L1 L1m L4 L4m nil))
(setq int2 (inters L2 L2m L3 L3m nil))
(setq ang1 (angle int2 L2))
(setq ang2 (angle int2 L3))
(command "Layer" "s" Lay "")

(alert "2")

(setvar "filletrad" 0)
(command "fillet" L1 L4)
(command "fillet" L2 L3)
(DrawLines)
(command "Layer" "s" cLay "" )
(setvar "filletrad" FRad)
(princ "\nDone...")
(princ)
)


(defun DrawLines ()
(command "line" int1 int2 "")
(command "line" (polar int2 ang1 LipDistance) (osnap L1 "perp") "")
(command "line" (polar int2 ang2 LipDistance) (osnap L4 "perp") "")
)


Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: my routine stopped working
« Reply #1 on: July 31, 2013, 10:40:38 AM »
After a cursory glance, try changing all instances of:
Code: [Select]
(command "Layer" ...)
to:
Code: [Select]
(command "_.-layer" ...)

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: my routine stopped working
« Reply #2 on: July 31, 2013, 10:42:27 AM »
It works fine here in AutoCAD 2013 (both with and w/o the 'alert')

What is QAFLAGS set to in your AutoCAD?

fixo

  • Guest
Re: my routine stopped working
« Reply #3 on: July 31, 2013, 05:12:57 PM »
@HelpLispinSeattle

Try to use instead:
Code: [Select]
(defun DrawLines ()
(command "line" "_non"int1 "_non"int2 "")
(command "line" "_non" (polar int2 ang1 LipDistance) "_non"(osnap L1 "perp") "")
(command "line" "_non"(polar int2 ang2 LipDistance) "_non"(osnap L4 "perp") "")
)

HelpLispinSeattle

  • Guest
Re: my routine stopped working
« Reply #4 on: August 01, 2013, 02:10:05 PM »
Thank you guys but it's still not working..QAFLAGS was set to zero.

Anyway, I studied some examples and made changes to the routine.
Now it works. Not sure if it was a better approach, and it needs some help.

There's a section wherein I wanted to substitute the old endpoints with new endpoints.
I wanted  to use entmod, entdel and entupd. But I did not have much success.

Can somebody please see if they can incorporate all these for learning purposes.

Different versions are welcome.

Code: [Select]
(defun c:test (/ Lay CLay FRad L1 L1m Ln ent Lay L2 L2e L2m  L3 L3m L4 L4m int1 int2 ang1 ang2 L1x L2x L3x L4x)
(if (not LipDistance) (setq LipDistance (* (getvar "Dimscale") 0.0625)))
(setq CLay (getvar"cLayer"))
(setvar "cmdecho" 0)
(setvar "orthomode" 0)
(princ "\nSelect the lines couter-clockwise. ")

(setq L1 (entsel "\nEnter OUTSIDE of branch duct<Nearest>: "))
(setq L1a (cdr (assoc 10 (entget (car L1)))))

(setq L1b (cdr (assoc 11 (entget (car L1)))))
(setq Lay (cdr (assoc 8 (entget (car L1)))))

(setq L2 (entsel "\nEnter INSIDE of branch duct<Perpendicular>: "))
(setq L2a (cdr (assoc 10 (entget (car L2)))))
(setq L2b (cdr (assoc 11 (entget (car L2)))))

(setq L3 (entsel "\nEnter INSIDE of main duct<Nearest>: "))
(setq L3a (cdr (assoc 10 (entget (car L3)))))
(setq L3b (cdr (assoc 11 (entget (car L3)))))

(setq L4 (entsel"\nEnter Opposite side of main duct<Perpendicular>: "))
(setq L4a (cdr (assoc 10 (entget (car L4)))))
(setq L4b (cdr (assoc 11 (entget (car L4)))))

(setq int1 (inters L1a L1b L4a L4b nil))
(setq int2 (inters L2a L2b L3a L3b nil))

(if (> (distance L1a int1) (distance L1b int1))(setq L1x L1a)(setq L1x L1b))
(if (> (distance L4a int1) (distance L4b int1))(setq L4x L4a)(setq L4x L4b))
(if (> (distance L2a int2) (distance L2b int2))(setq L2x L2a)(setq L2x L2b))
(if (> (distance L3a int2) (distance L3b int2))(setq L3x L3a)(setq L3x L3b))

(setq ang1 (angle int2 L2x))
(setq ang2 (angle int2 L3x))

;===================please modify this section===========================
(command "erase" L1 L2 L3 L4 "")
(command "_.-layer" "s" Lay "")
(command "line" L1x Int1 "")
(setq L1 (cdr (assoc 10 (entget (entlast)))))
(command "line" L2x Int2 "")
(command "line" L4x Int1 "")
(setq L4 (cdr (assoc 10 (entget (entlast)))))
(command "line" L3x Int2 "")
;========================================================================

(DrawLines)
(command "_.-layer" "s" cLay "" )
(princ "\nDone...")
(princ)

)

(defun DrawLines ()
(command "line" "_non"int1 "_non"int2 "")
(command "line" "_non" (polar int2 ang1 LipDistance) "_non"(osnap L1 "perp") "")
(command "line" "_non"(polar int2 ang2 LipDistance) "_non"(osnap L4 "perp") "")
)