TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: DEVITG on April 19, 2004, 05:50:20 PM
-
Hi I recieve this from a fellow .
(http://theswamp.org/lilly.pond/devitg/batt%20insulation.DWG)
Could it be done?????http://theswamp.org/lilly.pond/devitg/batt%20insulation.DWG
-
I'm pretty dam sure its a polyline created via a lisp routine.Architects use them a lisp to create cavity wall insulation.I've seen a lisp about for that,I'll see if I can dig it out for you.
(princ "\nInitial load, please wait...")
(defun C:INSUL (/
svbm ;"BLIPMODE"
sv_osmode ;"OSMODE"
poi1 ;Points which calculate the arcs and lines of the
;first batt.
poi2
poi3
poi4
poi5
poi6
poi7
iang ;Angle.
idis ;Approximate insulation length
iinc ;Increment distance.
;iwid ;Insulation width (global)
poic ;Center point of arc.
stpt ;Start point of insulation
)
(graphscr)
(setvar "CMDECHO" 0)
(command "UNDO" "M")
(setq svbm (getvar "BLIPMODE"))
(setq sv_osmode (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setq stpt (getpoint "\nStartpoint of insulation: "))
(if iwid
(setq prom (strcat " <" (rtos iwid) ">"))
(setq prom "")
)
(setq flag (getdist (strcat "\nInsulation width" prom ": ")))
(if flag
(setq iwid flag)
)
(setq endp
(getpoint stpt "\nPick insulation length and angle: ")
)
(setq iang (angle stpt endp))
(setq idis (distance stpt endp))
(princ "\nDrawing insulation segments...")
(setvar "BLIPMODE" 0)
(setvar "TRACEWID" 0)
(setq poi1 (polar stpt iang (* iwid 0.05)))
(setq iinc (distance poi1 stpt))
(setq poi2 (polar poi1 (+ (dtor 90) iang) (* iwid 0.30)))
(setq poi2 (polar poi2 (+ (dtor 180) iang) (* iwid 0.05)))
(command "PLINE" poi1 poi2)
(while (< iinc idis)
(setq poic (polar poi2 iang (* iwid 0.20)))
(setq iinc (+ (distance poic poi2) iinc))
(if (< iinc idis)
(progn
(setq poi3 (polar poic (+ (dtor 90) iang) (* iwid 0.20)))
(setq poi4 (polar poic iang (* iwid 0.20)))
(setq iinc (+ (distance poi4 poic) iinc))
(if (< iinc idis)
(progn
(command "ARC" "CE" poic "A" "-180")
(setq poi5 (polar poi4 (+ (dtor -90) iang) (* iwid 0.60)))
(setq poi5 (polar poi5 (+ (dtor 180) iang) (* iwid 0.10)))
(command "L" poi5)
(setq poic (polar poi5 iang (* iwid 0.20)))
(setq iinc (+ (* iwid 0.10) iinc))
(if (< iinc idis)
(progn
(setq poi6 (polar poic (+ (dtor -90) iang) (* iwid 0.20)))
(setq poi7 (polar poic iang (* iwid 0.20)))
(setq iinc (+ (* iwid 0.20) iinc))
(if (< iinc idis)
(progn
(command "ARC" "CE" poic poi7)
(setq poi2 (polar poi7 (+ (dtor 90) iang) (* iwid 0.60)))
(setq poi2 (polar poi2 (+ (dtor 180) iang) (* iwid 0.10)))
(command "L" poi2)
(setq iinc (- iinc (* iwid 0.10)))
)
(command "ARC" "CE" poic poi6)
)
)
)
)
(command "ARC" "CE" poic "A" "-90")
)
)
)
)
(command "")
(princ "\nProcessing completed...")
(setvar "BLIPMODE" svbm)
(setvar "OSMODE" sv_osmode)
(princ)
)
;
;*** End of Program
;*** Support Programs
;*** Function DTOR
;Converts degrees to radians, where degr is degrees; returns a
;radian value.
;
(defun DTOR (degr)
(/ (* degr pi) 180)
)
-
why not use the built in linetype definition of "batting" defined in the acad.lin file?
-
why not use the built in linetype definition of "batting" defined in the acad.lin file?
Hi Keith , I'm working on it .
I need to know where is saved or shown the heigth , in units , of such LINETYPE.
I do not why the same BATT line have diferent heigths , sized in units in diferent drawings .
I a dwg it have 0.40 it was unitless at UNITS
On other dwg , with mm as UNITS it draw a batt line with 20.28 mm.
Both have the same LINETYPESCALE 1
This what the batt line look at the acad.lin file
*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1
-
The linetype definition typically does not depend upon the units setting. If you have the units set to mm or unitless or imperial, the size of the line will be the same (well it should be) but remember if you insert a mm drawing into an imperial drawing, the scale will be 10/254 of the imperial size. therefore the ltscale in mm to have it display appropriately should probably be set to 1/25 or so
-
So , there is not any way to control the true size of a linetype.
Mi intention is to use it as a hatch.
Changing a circle draw in batt linetype to fit the pipe size and batt thick insulation.
The challenge is to hatch the sapce between the pipe's Out Dia and the insulation shield .
Normally the tick is in whole inches or 1" 2" and seldom in 1 1/2" or 2 1/2".
I will upload two dwf example wher you can see two batt lines with diferent heights.
Maybe it is not possible to change "mathematically" the linetype heigth.
-
If your interested, here is a lisp that works but there is some math error
because the pattern is not aligned perfectly.
I don't have time to look for the problem or maybe you can live with it.
;;; A function to draw batt insulation on an arc, line and polyline.
;;; Written By Theodorus Winata
;;;******* Returns a list containing the endpoints of the selected lwpoly segment *******
(defun balgetseg (selent /) ;elist pts tmp)
(setq selpt (osnap (cadr selent) "nea")
selpt (list (nth 0 selpt) (nth 1 selpt))
elist (entget (car selent))
)
(if (= (cdr (assoc 0 elist)) "LWPOLYLINE")
(progn
(setq pts (massoc 10 elist))
(if (isclosed (car selent))
(setq pts (append pts (list (car pts))))
)
(repeat (1- (length pts))
(if (equal (angle (car pts) selpt)
(angle selpt (cadr pts))
0.001
)
(setq tmp (list (car pts) (cadr pts)))
)
(setq pts (cdr pts))
)
tmp
)
)
)
;;; Returns: T if the lwpoly is closed, nil otherwise
(defun isclosed (poly)
(= 1 (logand 1 (cdr (assoc 70 (entget poly)))))
)
;;; Returns a list containing cdrs for every occurence of key in alist
(defun massoc (key alist)
(apply 'append
(mapcar '(lambda (x)
(if (eq (car x) key)
(list (cdr x))
)
)
alist
)
)
)
;;; *********** Arc Information **************
(defun ar-info ()
(setq BS (strcase (getstring "\nBatt Inside or Outside the Arc? [I/O] <O>: "))
WD (getdist "\nWidth of batt insulation: ")
NS (getint "\nNumber of segments: ")
LI (entget (car LI))
CT (cdr (assoc 10 LI))
RA (cdr (assoc 40 LI))
AN (cdr (assoc 51 LI))
A1 (cdr (assoc 50 LI))
SP (polar CT AN RA)
EP (polar CT A1 RA)
SA AN
EA A1
FIL (rtd (- EA SA))
AX (+ SA (/ pi 2.0))
AT (/ FIL NS)
COUNT 0
SS (ssadd)
);;setq
);;arc-info
;;; *********** Radian to Degree Conversion **************
(defun rtd (a) (/ (* a 180.0) pi))
;;; *********** Main Program **************
(defun C:BAL (/ AN AX CME COUNT DX E1 E2 E3 E4 E5 EP ET LI
M:ERR NU NX OSM P1 P2 P3 P4 P5 P6 P7 SP SS WD)
(setq M:ERR *ERROR* *ERROR* *MERR*
CME (getvar "CMDECHO")
OSM (getvar "OSMODE")
);;setq
(setvar "CMDECHO" 0) (setvar "OSMODE" 0)
(while (null LI)
(setq LI (entsel "\nPick arc/line/polyline for batt insulation location: "))
(if LI
(cond
((= (cdr (assoc 0 (entget (car LI)))) "ARC")
(ar-info)
(if (or (= BS "") (= BS "O"))
(progn
(setq P1 (polar SP SA (/ WD 1.25))
P2 (polar P1 AX (/ WD 5.0))
P3 (polar P1 AX (/ WD 2.5))
P4 (polar SP SA (/ WD 5.0))
P5 (polar P4 AX (/ WD 5.0))
P6 (polar P4 AX (/ WD 2.5))
P7 (polar SP AX (/ WD 2.5))
);;setq
(command "_.Arc" "C" P4 P5 SP)
(setq E1 (entlast))
(command "_.Line" P5 P1 "")
(setq E2 (entlast))
(command "_.Line" P5 P3 "")
(setq E3 (entlast))
(command "_.Arc" "C" P6 P7 P5)
(setq E4 (entlast))
(command "_.Arc" P1 "C" P2 "A" "180")
(setq E5 (entlast))
(command "_.Pedit" E1 "Y" "J" E2 E3 E4 E5 "" "")
(ssadd (entlast) SS)
(while (/= COUNT NS)
(progn
(command "_.Copy" (entlast) "" CT CT
"_.Rotate" (entlast) "" CT AT)
(ssadd (entlast) SS)
(setq COUNT (+ COUNT 1))
);;progn
);;while
(command "-Group" "" "*" "" SS "")
);;progn
);;if O
(if (= BS "I")
(progn
(setq P1 (polar SP (+ SA pi) (/ WD 1.25))
P2 (polar P1 AX (/ WD 5.0))
P3 (polar P1 AX (/ WD 2.5))
P4 (polar SP (+ SA pi) (/ WD 5))
P5 (polar P4 AX (/ WD 5.0))
P6 (polar P4 AX (/ WD 2.5))
P7 (polar SP AX (/ WD 2.5))
);;setq
(command "_.Arc" "C" P4 SP P5)
(setq E1 (entlast))
(command "_.Line" P5 P1 "")
(setq E2 (entlast))
(command "_.Line" P5 P3 "")
(setq E3 (entlast))
(command "_.Arc" "C" P6 P5 P7)
(setq E4 (entlast))
(command "_.Arc" P1 "C" P2 "A" "-180")
(setq E5 (entlast))
(command "_.Pedit" E1 "Y" "J" E2 E3 E4 E5 "" "")
(ssadd (entlast) SS)
(while (/= COUNT NS)
(progn
(command "_.Copy" (entlast) "" CT CT
"_.Rotate" (entlast) "" CT AT)
(ssadd (entlast) SS)
(setq COUNT (+ COUNT 1))
);;progn
);;while
(command "-Group" "" "*" "" SS "")
);;progn
);;if I
);;ARC
((= (cdr (assoc 0 (entget (car LI)))) "LINE")
(setq LI (entget (car LI))
SP (cdr (assoc 10 LI))
EP (cdr (assoc 11 LI))
AN (angle SP EP)
DX (distance SP EP)
AX (+ AN (/ pi 2.0))
WD (getdist "\nWidth of batt insulation: ")
NX (/ WD 2.5)
NU (/ DX NX)
P1 (polar SP AX (/ WD 1.25))
P2 (polar P1 AN (/ WD 5.0))
P3 (polar P1 AN (/ WD 2.5))
P4 (polar SP AX (/ WD 5.0))
P5 (polar P4 AN (/ WD 5.0))
P6 (polar P4 AN (/ WD 2.5))
P7 (polar SP AN (/ WD 2.5))
SS (ssadd)
);;setq
(repeat (fix (+ NU 1))
(command "_.Arc" "C" P4 SP P5)
(setq E1 (entlast))
(command "_.Line" P5 P1 "")
(setq E2 (entlast))
(command "_.Arc" P1 "C" P2 "A" "-180")
(setq E3 (entlast))
(command "_.Line" P3 P5 "")
(setq E4 (entlast))
(command "_.Arc" "C" P6 P5 P7)
(setq E5 (entlast))
(command "_Pedit" E1 "Y" "J" E2 E3 E4 E5 "" "")
(ssadd (entlast) SS)
(setq SP (polar SP AN NX)
P1 (polar P1 AN NX)
P2 (polar P2 AN NX)
P3 (polar P3 AN NX)
P4 (polar P4 AN NX)
P5 (polar P5 AN NX)
P6 (polar P6 AN NX)
P7 (polar P7 AN NX)
);;setq
);;repeat
(command "_.Pedit" SS "J" SS "" "")
);;LINE
((= (cdr (assoc 0 (entget (car LI)))) "LWPOLYLINE")
(setq LI (balgetseg LI)
SP (car LI)
EP (cadr LI)
AN (angle SP EP)
DX (distance SP EP)
AX (+ AN (/ pi 2.0))
WD (getdist "\nWidth of batt insulation: ")
NX (/ WD 2.5)
NU (/ DX NX)
P1 (polar SP AX (/ WD 1.25))
P2 (polar P1 AN (/ WD 5.0))
P3 (polar P1 AN (/ WD 2.5))
P4 (polar SP AX (/ WD 5.0))
P5 (polar P4 AN (/ WD 5.0))
P6 (polar P4 AN (/ WD 2.5))
P7 (polar SP AN (/ WD 2.5))
SS (ssadd)
);;setq
(repeat (fix (+ NU 1))
(command "_.Arc" "C" P4 SP P5)
(setq E1 (entlast))
(command "_.Line" P5 P1 "")
(setq E2 (entlast))
(command "_.Arc" P1 "C" P2 "A" "-180")
(setq E3 (entlast))
(command "_.Line" P3 P5 "")
(setq E4 (entlast))
(command "_.Arc" "C" P6 P5 P7)
(setq E5 (entlast))
(command "_Pedit" E1 "Y" "J" E2 E3 E4 E5 "" "")
(ssadd (entlast) SS)
(setq SP (polar SP AN NX)
P1 (polar P1 AN NX)
P2 (polar P2 AN NX)
P3 (polar P3 AN NX)
P4 (polar P4 AN NX)
P5 (polar P5 AN NX)
P6 (polar P6 AN NX)
P7 (polar P7 AN NX)
);;setq
);;repeat
(command "_.Pedit" SS "J" SS "" "")
);;LWPOLYLINE
(T (setq LI nil) (alert "\" Select An Arc/Line/Polyline, Dude !\""))
);;cond
(alert "\" Nothing Selected, Dude. Try Again !\"")
);;if LI
);;while LI
(setvar "CMDECHO" CME) (setvar "OSMODE" OSM)
(setq *ERROR* M:ERR M:ERR nil)
(princ)
);;C:BAL
(prompt "\nType < BAL > to execute.")
(princ)
-
Hi Cab.
I will see it and try to fix.
Thanks.
-
Here's another one..
(princ "Type <batt2> to run...")
(defun newerr (NE)
(if (/= NE "Function cancelled")
(princ (strcat "\nError: " NE))
)
(setvar "OSMODE" OM)
(setvar "CMDECHO" CE)
(setvar "BLIPMODE" BM)
(princ)
)
(defun c:BATT2
(/ SP EP HT OM CE BM DX AN NX NU AX PX P1 P2 P3 P4 P5
P6 P7 P8 P9 XT)
(while (= SP nil)
(setq SP
(getpoint "\nPick start point of batting: ")
)
)
(while (= EP nil)
(setq EP
(getpoint "\nPick end point of batting: ")
)
)
(while (= HT nil)
(setq HT
(getdist "\nPick or enter height of batting: ")
)
)
(setq OM (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setq CE (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq BM (getvar "BLIPMODE"))
(setvar "BLIPMODE" 0)
(setq DX (distance SP EP)
AN (angle SP EP)
NX (/ HT 2)
NU (/ DX NX)
AX (+ AN (/ pi 2))
PX (polar SP AX HT)
P1 (polar SP AX (/ HT 1.25))
P2 (polar P1 AN (/ HT 20))
P3 (polar P1 AN (/ HT 4))
P4 (polar P2 AN (/ HT 2.5))
P5 (polar SP AX (/ HT 5))
P6 (polar P5 AN (/ HT 5))
P7 (polar P6 AN (/ HT 10))
P8 (polar P5 AN (/ HT 2))
P9 (polar SP AN (/ HT 2))
)
(repeat (fix NU)
(command ".ARC" "C" P5 SP P6 ".LINE" P6
P2 "" ".ARC" P2 "C" P3 "A" "-180"
".LINE" P4 P7 "" ".ARC" "C" P8
P7 P9
)
(setq SP (polar SP AN NX)
P2 (polar P2 AN NX)
P3 (polar P3 AN NX)
P4 (polar P4 AN NX)
P5 (polar P5 AN NX)
P6 (polar P6 AN NX)
P7 (polar P7 AN NX)
P8 (polar P8 AN NX)
P9 (polar P9 AN NX)
)
)
(setq XT (distance SP EP))
(if (>= XT (/ HT 5))
(command ".ARC" "C" P5 SP P6 ".LINE" P6 P2 "" ".ARC" P2 "C" P3 "A"
"-75")
)
(setvar "OSMODE" OM)
(setvar "CMDECHO" CE)
(setvar "BLIPMODE" BM)
(princ)
)
-
Here's a dialog driven insulate thingy (contains a command line version, too).
lisp file (http://www.smadsen.com/files/insulate09.LSP)
dcl file (http://www.smadsen.com/files/ddins.DCL)
Rename the lisp file to whatever but don't rename the dcl.
Commands are DDINS for the dialog thingy and INSUL for command line ditto. It was originally made to draw wedge-shaped insulation so it emphasizes on that but straight insulation is of course possible, also.
I won't support it (read: for free) so please don't make requests for alterations.
-
WB & Stig, he is trying to align the batt with an arc.
Devitg let me know if you get that BAL.lsp routine to behave, I would like a copy.
CAB
-
Hi CAB , I did not even check the bal.lsp , just start a new one with out any "contamination"
I made this lisp
http://theswamp.org/lilly.pond/devitg/batt-to%20cab.dwg
and use it on this draw .
http://theswamp.org/lilly.pond/devitg/battinsulation-usr%20input01-to%20cab.LSP
It has no comment , because they where in spanish
-
Give me some time to digest the lisp.
The output drawing looks great.
CAB
-
Hi Cab , I digest it for you . :lol:
http://theswamp.org/lilly.pond/devitg/battinsulation-usr%20input01-to%20cabDIGESTED.LSP