-
Notifications
You must be signed in to change notification settings - Fork 5
/
LayOutColumnGrid.lsp
225 lines (180 loc) · 7.4 KB
/
LayOutColumnGrid.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
(defun C:LAYOutColumnGrid( / i j osm Origin Origin_X Origin_Y ColSizeX ColSizeY P_G1 PG2 P_D1 PD2
GridRows GridColumns LstRows LstColumns CoordLstRows CoordLstColumns EqInterval offorigin Arrowsize TxtHt Dec Gap Extline1 Extline2 distDim Out_In
DmToh DmTih)
;This autoLisp program is written by Ajay Yadav (AY) and named as L-AY-OutColumnGrid i.e. LAYOutColumnGrid.
;Download from https://github.com/ajayyadavay/AutocadAutoLisp
;Choose origin
;Enter interval of grid in x and y axis
;(setq ColSizeX 0.23 ColSizeY 0.23)
(setq ColSizeX (getreal "\nEnter Column size in X direction: " )); ColumnsizeX
(setq ColSizeY (getreal "\nEnter Column size in Y direction: " )); ColumnsizeY
(setq Origin (getpoint "\nChoose Origin:"))
(setq Origin_X (car Origin))
(setq Origin_Y (car (cdr Origin)))
(setq LstRows (append LstRows (list Origin_Y)))
(setq LstColumns (append LstColumns (list Origin_X)))
(setq osm (getvar "osmode"))
(setvar "osmode" 0)
;input data of interval between grids
(setq GridRows (getint "\nEnter no. of grid in rows (in X Dir):")); X-axis gridlines
(setq GridColumns (getint "\nEnter no. of grid in columns (in Y Dir):")); Y-axis gridlines
(setq i 0)
(repeat (- GridRows 1)
(setq i (+ i 1))
(setq EqInterval (getreal (strcat "\nEnter interval of GridRows " (itoa i) " : "))); Gridline Row interval
(setq LstRows (append LstRows (list EqInterval)))
)
;LstRows contains list in string data type
;(princ LstRows)
(setq j 0)
(repeat (- GridColumns 1)
(setq j (+ j 1))
(setq EqInterval (getreal (strcat "\nEnter interval of GridColumns " (itoa j) " : "))); Gridline Column interval
(setq LstColumns (append LstColumns (list EqInterval)))
)
;LstColumns contains list in string data type
;(princ LstColumns)
;end input data
;Create center to center coordinates
;CoordLstRows contains list in real data type
(setq CoordLstRows (append CoordLstRows (list (nth 0 LstRows))))
(setq i 0)
(repeat (- GridRows 1)
(setq i (+ i 1))
(setq CoordLstRows (append CoordLstRows (list(+ (nth (- i 1) CoordLstRows) (nth i LstRows)))))
)
;CoordLstColumns contains list in real data type
(setq CoordLstColumns (append CoordLstColumns (list (nth 0 LstColumns))))
(setq i 0)
(repeat (- GridColumns 1)
(setq i (+ i 1))
(setq CoordLstColumns (append CoordLstColumns (list(+ (nth (- i 1) CoordLstColumns) (nth i LstColumns)))))
)
;end coordinates
;dimension
(setq offorigin (getvar "dimexo"))
(setq Arrowsize (getvar "dimasz"))
(setq TxtHt (getvar "dimtxt"))
(setq Dec (getvar "dimdec"))
(setq Gap (getvar "dimgap"))
(setq Extline1 (getvar "dimse1"))
(setq Extline2 (getvar "dimse2"))
(setvar "dimexo" 0.15)
(setvar "dimasz" 0.4)
(setvar "dimtxt" 0.3)
(setvar "dimdec" 3)
(setvar "dimgap" 0.25)
(setvar "dimse1" 1)
(setvar "dimse2" 1)
(setvar "dimtih" 0)
(setvar "dimtoh" 0)
;Draw Grid lines along X direction
(setq i -1)
(repeat (+ GridRows 0)
(setq i (+ i 1))
(setq j -1)
(repeat (- GridColumns 1)
(setq j (+ j 1))
(setq P_G1 (list (+ (nth j CoordLstColumns) 0) (+ (nth i CoordLstRows) 0)))
(setq P_G2 (list (+ (nth (+ j 1) CoordLstColumns) 0) (+ (nth (+ i 0) CoordLstRows) 0) ))
(command "-layer" "m" "Grindline" "c" "t" "34,247,247" "Grindline" "")
(command "line" P_G1 P_G2 "")
;column
(command "-layer" "m" "Column" "c" "t" "255,0,0" "Column" "")
(setq P_D1 (list (- (car P_G1) (/ ColSizeX 2)) (- (car (cdr P_G1)) (/ ColSizeY 2))))
(setq P_D2 (list (+ (car P_G1) (/ ColSizeX 2)) (+ (car (cdr P_G1)) (/ ColSizeY 2))))
(command "rectangle" P_D1 P_D2)
)
;column
(command "-layer" "m" "Column" "c" "t" "255,0,0" "Column" "")
(setq P_D1 (list (- (car P_G2) (/ ColSizeX 2)) (- (car (cdr P_G2)) (/ ColSizeY 2))))
(setq P_D2 (list (+ (car P_G2) (/ ColSizeX 2)) (+ (car (cdr P_G2)) (/ ColSizeY 2))))
(command "rectangle" P_D1 P_D2)
)
;End drawing grid lines along X direction
;dimension along X direction bottom
(repeat 1
(setq i 0)
(setq j -1)
(repeat (- GridColumns 1)
(setq j (+ j 1))
(setq P_G1 (list (+ (nth j CoordLstColumns) 0) (+ (nth i CoordLstRows) 0)))
(setq P_G2 (list (+ (nth (+ j 1) CoordLstColumns) 0) (+ (nth (+ i 0) CoordLstRows) 0) ))
(command "-layer" "m" "Dimension" "c" "t" "249,245,6" "Dimension" "")
(setq distDim (+ ColSizeY 0.5) Out_In -1)
(command "dimaligned" P_G1 P_G2 (list(+(car P_G1) 0) (+ (cadr P_G1) (* Out_In distDim))));center to center distance
)
)
;End dimension along X direction bottom
;dimension along X direction Top
(repeat 1
(setq i (- GridRows 1))
(setq j -1)
(repeat (- GridColumns 1)
(setq j (+ j 1))
(setq P_G1 (list (+ (nth j CoordLstColumns) 0) (+ (nth i CoordLstRows) 0)))
(setq P_G2 (list (+ (nth (+ j 1) CoordLstColumns) 0) (+ (nth (+ i 0) CoordLstRows) 0) ))
(command "-layer" "m" "Dimension" "c" "t" "249,245,6" "Dimension" "")
(setq distDim (+ ColSizeY 0.5) Out_In 1)
(command "dimaligned" P_G1 P_G2 (list(+(car P_G1) 0) (+ (cadr P_G1) (* Out_In distDim))));center to center distance
)
)
;End dimension along X direction Top
;Draw Grid lines along Y direction
(setq i -1)
(repeat (+ GridColumns 0)
(setq i (+ i 1))
(setq j -1)
(repeat (- GridRows 1)
(setq j (+ j 1))
(setq P_G1 (list (+ (nth i CoordLstColumns) 0) (+ (nth j CoordLstRows) 0)))
(setq P_G2 (list (+ (nth (+ i 0) CoordLstColumns) 0) (+ (nth (+ j 1) CoordLstRows) 0) ))
(command "-layer" "m" "Grindline" "c" "t" "34,247,247" "Grindline" "")
(command "line" P_G1 P_G2 "")
)
)
;End drawing grid lines along Y direction
;dimension along Y direction Left
(setq i -1)
(repeat 1
(setq i (+ i 1))
(setq j -1)
(repeat (- GridRows 1)
(setq j (+ j 1))
(setq P_G1 (list (+ (nth i CoordLstColumns) 0) (+ (nth j CoordLstRows) 0)))
(setq P_G2 (list (+ (nth (+ i 0) CoordLstColumns) 0) (+ (nth (+ j 1) CoordLstRows) 0) ))
(command "-layer" "m" "Dimension" "c" "t" "249,245,6" "Dimension" "")
(setq distDim (+ ColSizeX 0.5) Out_In -1)
(command "dimaligned" P_G1 P_G2 (list(+(car P_G1) (* Out_In distDim)) (+ (cadr P_G1) 0)));center to center distance
)
)
;End dimension along Y direction Left
;dimension along Y direction Right
;(setq i -1)
(repeat 1
(setq i (- GridColumns 1))
(setq j -1)
(repeat (- GridRows 1)
(setq j (+ j 1))
(setq P_G1 (list (+ (nth i CoordLstColumns) 0) (+ (nth j CoordLstRows) 0)))
(setq P_G2 (list (+ (nth (+ i 0) CoordLstColumns) 0) (+ (nth (+ j 1) CoordLstRows) 0) ))
(command "-layer" "m" "Dimension" "c" "t" "249,245,6" "Dimension" "")
(setq distDim (+ ColSizeX 0.5) Out_In 1)
(command "dimaligned" P_G1 P_G2 (list(+(car P_G1) (* Out_In distDim)) (+ (cadr P_G1) 0)));center to center distance
)
)
;End dimension along Y direction Right
;Reset values
(setvar "dimexo" offorigin)
(setvar "dimasz" Arrowsize)
(setvar "dimtxt" TxtHt)
(setvar "dimdec" Dec)
(setvar "dimgap" Gap)
(setvar "dimse1" Extline1)
(setvar "dimse2" Extline2)
(setvar "osmode" osm)
(setvar "dimtoh" DmToh)
(setvar "dimtih" DmTih)
(gc)
(princ)
)