Advertisement
inf926k

Untitled

Dec 18th, 2016
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.56 KB | None | 0 0
  1. (command "_.osnap" "_none")
  2. (command "_erase" "All" "")
  3.  
  4. (defun draw1 (l1 sh vi shkv1 shkv2 dlvn)
  5. ; Calc points
  6. (setq p2 (polar l1 0 dl))
  7. (setq p3 (polar p2 (* 3 (/ Pi 2)) (/ (- vi shkv1) 2)))
  8. (setq p4 (polar p3 Pi (/ (- dl dlvn) 2)))
  9. (setq p5 (polar p4 (* 3 (/ Pi 2)) shkv1))
  10. (setq p6 (polar p5 0 (/ (- dl dlvn) 2)))
  11. (setq p7 (polar p6 (* 3 (/ Pi 2)) (/ (- vi shkv1) 2)))
  12. (setq p8 (polar p7 Pi dl))
  13. (setq p9 (polar p8 (/ Pi 2) (/ (- vi shkv1) 2)))
  14. (setq p10 (polar p9 0 (/ (- dl dlvn) 2)))
  15. (setq p11 (polar p10 (/ Pi 2) shkv1))
  16. (setq p12 (polar p11 Pi (/ (- dl dlvn) 2)))
  17.  
  18. (setq pcx (polar l1 0 (- (/ dl 2) (/ shkv2 2))))
  19. (setq pc1 (polar pcx (* 3 (/ Pi 2)) (- (/ vi 2) (/ shkv2 2))))
  20. ;(setq pc1 (polar pcx (* 3 (/ Pi 2)) (- (/ vi 2) (/ shkv2 2)) ))
  21. (setq pc2 (polar pc1 0 shkv2))
  22. (setq pc3 (polar pc2 (* 3 (/ Pi 2)) shkv2))
  23. (setq pc4 (polar pc3 Pi shkv2))
  24.  
  25. (setq p13 (polar p12 0 (- (/ dl 2) (/ shkv2 2))))
  26. (setq p14 (polar p13 (* 3 (/ Pi 2)) shkv1))
  27. (setq p15 (polar p3 (- 0 Pi) (- (/ dl 2) (/ shkv2 2))))
  28. (setq p16 (polar p15 (* 3 (/ Pi 2)) shkv1))
  29.  
  30. (setq phatch1 (polar p8 (/ Pi 4) 1))
  31. (setq phatch2 (polar p12 (/ Pi 4) 1))
  32.  
  33. ; Draw main lines
  34. (command "_.Layer" "_Make" "main_lines" "_Color"
  35. "250" "" "LType" "Continuous"
  36. "" ""
  37. )
  38. (command "_layer" "lw" 0.30 "main_lines" "")
  39. (command "_line" l1 p2 p3 "")
  40. (cond
  41. (
  42. (/= 0 shkv1)
  43. (command "_line" p4 p3 "")
  44. (command "_line" p5 p6 "")
  45. (command "_line" p9 p10 "")
  46. (command "_line" p11 p12 "")
  47. )
  48. )
  49. (command "_line" p4 p5 "")
  50. (command "_line" p6 p7 p8 p9 "")
  51. (command "_line" p10 p11 "")
  52. (command "_line" p12 l1 "")
  53.  
  54. (command "_line" pc1 pc2 pc3 pc4 pc1 "")
  55.  
  56. (command "_.Layer" "_Make" "hidden_lines"
  57. "_Color" "250" "" "LType"
  58. "Continuous" "" ""
  59. )
  60. (command "_layer" "lw" 0.20 "hidden_lines" "")
  61.  
  62. (cond
  63. (
  64. (/= 0 shkv1)
  65. (command "_line" p4 p3 "")
  66. (command "_line" p4 p15 "")
  67.  
  68. (command "_line" p5 p16 "")
  69.  
  70. (command "_line" p11 p13 "")
  71. (command "_line" p10 p14 "")
  72.  
  73. )
  74. (
  75. (and (/= 0 shkv1) (/= 0 shkv2))
  76. (command "_line" p13 pc1 "")
  77. (command "_line" p14 pc4 "")
  78. (command "_line" p16 pc3 "")
  79. (command "_line" pc2 p15 "")
  80. )
  81. )
  82. (cond
  83. (
  84. (> shkv1 shkv2)
  85. (command "_line" p13 p15 "")
  86. (command "_line" p14 p16 "")
  87. )
  88. )
  89.  
  90. ; Draw hatch
  91. (command "_.Layer" "_Make" "hatch_lines" "_Color"
  92. "250" "" "LType" "Continuous"
  93. "" ""
  94. )
  95. (command "_bhatch" "_a" "" "_p" "_ansi31" "0.5" "30" phatch1 "" "")
  96. (command "_bhatch" "_a" "" "_p" "_ansi31" "0.5" "30" phatch2 "" "")
  97.  
  98. ; Draw dimens
  99. (command "_.Layer" "_Make" "dimens" "_Color" "64"
  100. "" "LType" "Continuous" ""
  101. ""
  102. )
  103. (command "dimlinear" l1 p2 (polar p1 (/ Pi 2) 5))
  104. (cond
  105. (
  106. (and (/= 0 shkv1) (= 0 shkv2))
  107. (command "dimlinear" p10 p5 (polar p10 (* 3 (/ Pi 2)) 15))
  108. (command "dimlinear" p9 p12 (polar p9 0 -5))
  109. )
  110. (
  111. (and (/= 0 shkv1) (/= 0 shkv2))
  112. (command "dimlinear" p10 p5 (polar p10 (* 3 (/ Pi 2)) 15))
  113. (command "dimlinear" p9 p12 (polar p9 0 -5))
  114.  
  115. (command "dimlinear" pc2 pc3 (polar pc2 0 -5))
  116. )
  117. (
  118. (and (= 0 shkv1) (/= 0 shkv2))
  119. )
  120. )
  121.  
  122.  
  123. ; Draw names
  124. (command "_.Layer" "_Make" "dim_names" "_Color" "64"
  125. "" "LType" "Continuous" ""
  126. ""
  127. )
  128. (command "dimlinear" p1 p2 (polar p1 (/ Pi 2) 5))
  129. (cond
  130. (
  131. (and (/= 0 shkv1) (= 0 shkv2))
  132. (command "dimlinear" p10 p5 (polar p10 (* 3 (/ Pi 2)) 15))
  133. (command "dimlinear" p9 p12 (polar p9 0 -5))
  134. )
  135. (
  136. (and (/= 0 shkv1) (/= 0 shkv2))
  137. (command "dimlinear" p10 p5 (polar p10 (* 3 (/ Pi 2)) 15))
  138. (command "dimlinear" p9 p12 (polar p9 0 -5))
  139.  
  140. (command "dimlinear" pc2 pc3 (polar pc2 0 -5))
  141. )
  142. (
  143. (and (= 0 shkv1) (/= 0 shkv2))
  144. )
  145. )
  146.  
  147. (command "dimlinear" p1 p8 (polar p1 0 -10))
  148.  
  149. ; Draw Point names
  150. (command "_.Layer" "_Make" "point_names" "_Color"
  151. "17" "" "LType" "Continuous"
  152. "" ""
  153. )
  154. (command "_text" p1 "2" "0" "p1" "")
  155. (command "_text" p2 "2" "0" "p2" "")
  156.  
  157. (command "_text" p7 "2" "0" "p7" "")
  158. (command "_text" p8 "2" "0" "p8" "")
  159. (cond
  160. (
  161. (and (/= 0 shkv1) (/= 0 shkv2))
  162. (command "_text" p3 "2" "0" "p3" "")
  163. (command "_text" p4 "2" "0" "p4" "")
  164. (command "_text" p5 "2" "0" "p5" "")
  165. (command "_text" p6 "2" "0" "p6" "")
  166. (command "_text" p9 "2" "0" "p9" "")
  167. (command "_text" p10 "2" "0" "p10" "")
  168. (command "_text" p11 "2" "0" "p11" "")
  169. (command "_text" p12 "2" "0" "p12" "")
  170. (command "_text" p13 "2" "0" "p13" "")
  171. (command "_text" p14 "2" "0" "p14" "")
  172. (command "_text" p15 "2" "0" "p15" "")
  173. (command "_text" p16 "2" "0" "p16" "")
  174. (command "_text" pc1 "2" "0" "pc1" "")
  175. (command "_text" pc2 "2" "0" "pc2" "")
  176. (command "_text" pc3 "2" "0" "pc3" "")
  177. (command "_text" pc4 "2" "0" "pc4" "")
  178. )
  179. (
  180. (and (/= 0 shkv1) (= 0 shkv2))
  181. (command "_text" p3 "2" "0" "p3" "")
  182. (command "_text" p4 "2" "0" "p4" "")
  183. (command "_text" p5 "2" "0" "p5" "")
  184. (command "_text" p6 "2" "0" "p6" "")
  185. (command "_text" p9 "2" "0" "p9" "")
  186. (command "_text" p10 "2" "0" "p10" "")
  187. (command "_text" p11 "2" "0" "p11" "")
  188. (command "_text" p12 "2" "0" "p12" "")
  189. )
  190. (
  191. (and (= 0 shkv1) (/= 0 shkv2))
  192. (command "_text" pc1 "2" "0" "pc1" "")
  193. (command "_text" pc2 "2" "0" "pc2" "")
  194. (command "_text" pc3 "2" "0" "pc3" "")
  195. (command "_text" pc4 "2" "0" "pc4" "")
  196. )
  197. )
  198. )
  199. (defun draw2 (l1 sh vi shkv1 shkv2 dlvn)
  200. ; Calc points
  201. (setq l2 (polar l1 0 sh))
  202. (setq l3 (polar l2 (* 3 (/ Pi 2)) vi))
  203. (setq l4 (polar l1 (* 3 (/ Pi 2)) vi))
  204.  
  205. (setq pcx (polar l1 0 (/ (- sh shkv1) 2) ) )
  206. (setq lc1 (polar pcx (* 3 (/ Pi 2)) (/ (- vi shkv1) 2) ) )
  207. (setq lc4 (polar lc1 (* 3 (/ Pi 2)) shkv1 ))
  208. (setq lc2 (polar lc1 0 shkv1 ))
  209. (setq lc3 (polar lc4 0 shkv1 ))
  210.  
  211. (setq l5 (polar l1 (* 3 (/ Pi 2)) (/ (- vi shkv2) 2) ) )
  212. (setq l7 (polar l5 (* 3 (/ Pi 2)) shkv2 ))
  213. (setq l6 (polar l2 (* 3 (/ Pi 2)) (/ (- vi shkv2) 2) ) )
  214. (setq l8 (polar l6 (* 3 (/ Pi 2)) shkv2 ))
  215.  
  216. (setq c1 (polar l5 0 (/ (- sh shkv1) 2) ) )
  217. (setq c2 (polar c1 0 shkv1 ))
  218. (setq c3 (polar c2 (* 3 (/ Pi 2)) shkv2 ) )
  219. (setq c4 (polar c1 (* 3 (/ Pi 2)) shkv2 ))
  220.  
  221.  
  222.  
  223.  
  224. ; Draw main lines
  225. (command "_.Layer" "_Make" "main_lines" "_Color" "250" "" "LType" "Continuous" "" "")
  226. (command "_layer" "lw" 0.30 "main_lines" "")
  227. (command "_line" l1 l2 l3 l4 l1 "")
  228. (cond
  229. (
  230. (/= 0 shkv1)
  231. (command "_line" lc1 lc2 lc3 lc4 lc1 "")
  232. )
  233. )
  234.  
  235. ; Draw hidden lines
  236. (command "_.Layer" "_Make" "hidden_lines" "_Color" "250" "" "LType" "Continuous" "" "")
  237. (command "_layer" "lw" 0.10 "hidden_lines" "")
  238. (cond
  239. (
  240. (< shkv1 shkv2)
  241. (command "_line" c1 c2 "")
  242. (command "_line" c4 c3 "")
  243. )
  244. )
  245. (cond
  246. (
  247. (/= 0 shkv2)
  248. (command "_line" l5 c1 "")
  249. (command "_line" l6 c2 "")
  250. (command "_line" l8 c3 "")
  251. (command "_line" l7 c4 "")
  252. )
  253. )
  254.  
  255.  
  256. ; Draw dimens
  257. (command "_.Layer" "_Make" "dimens" "_Color" "64" "" "LType" "Continuous" "" "")
  258. (command "dimlinear" l2 l3 (polar l2 0 5 ) )
  259. (command "dimlinear" l4 l3 (polar l3 (* 3 (/ Pi 2)) 5 ) )
  260. (cond
  261. (
  262. (/= shkv1 0)
  263. (command "dimlinear" lc2 lc3 (polar lc2 0 5 ) )
  264. )
  265. )
  266. (cond
  267. (
  268. (/= shkv2 0)
  269. (command "dimlinear" l5 l7 (polar l7 Pi 5 ) )
  270. )
  271. )
  272.  
  273. ; Draw Point names
  274. (command "_.Layer" "_Make" "point_names" "_Color" "17" "" "LType" "Continuous" "" "")
  275. (command "_text" l1 "2" "0" "l1" "")
  276. (command "_text" l2 "2" "0" "l2" "")
  277. (command "_text" l3 "2" "0" "l3" "")
  278. (command "_text" l4 "2" "0" "l4" "")
  279. (cond
  280. (
  281. (/= 0 shkv1)
  282. (command "_text" lc1 "2" "0" "lc1" "")
  283. (command "_text" lc2 "2" "0" "lc2" "")
  284. (command "_text" lc3 "2" "0" "lc3" "")
  285. (command "_text" lc4 "2" "0" "lc4" "")
  286. )
  287. )
  288. (cond
  289. (
  290. (/= 0 shkv2)
  291. (command "_text" l5 "2" "0" "l5" "")
  292. (command "_text" l6 "2" "0" "l6" "")
  293. (command "_text" l7 "2" "0" "l7" "")
  294. (command "_text" l8 "2" "0" "l8" "")
  295. )
  296. )
  297. (cond
  298. (
  299. (and (< shkv1 shkv2) (/= 0 shkv1))
  300. (command "_text" c1 "2" "0" "c1" "")
  301. (command "_text" c2 "2" "0" "c2" "")
  302. (command "_text" c3 "2" "0" "c3" "")
  303. (command "_text" c4 "2" "0" "c4" "")
  304. )
  305. )
  306. )
  307.  
  308. (defun drawAll (p1 sh vi shkv1 shkv2 dlvn)
  309. (draw1 p1 sh vi shkv1 shkv2 dlvn)
  310. (setq c1 (polar p1 0 (* dl 1.2)))
  311. (draw2 c1 sh vi shkv1 shkv2 dlvn)
  312. (setq c1 (polar p1 0 (* dl 1.2)))
  313. ; Draw axis
  314. (command "_.Layer" "_Make" "axiss1" "_Color" "250"
  315. "" "LType" "ACAD_ISO10W100" ""
  316. ""
  317. )
  318. ; X axis
  319. (setq caxLeftWithoutMargin (polar p1 (* 3 (/ Pi 2)) (/ vi 2)))
  320. (setq caxRightWithoutMargin (polar caxLeftWithoutMargin 0 (+ (* 1.2 dl) sh)))
  321. (setq caxLeftWithMargin (polar caxLeftWithoutMargin 0 -30))
  322. (setq caxRightWithMargin (polar caxRightWithoutMargin 0 30))
  323. (command "_line" caxLeftWithMargin caxRightWithMargin "")
  324. ; Y axis
  325. (setq cayFirstUpWithoutMargin (polar p1 0 (/ dl 2)))
  326. (setq cayFirstDownWithoutMargin (polar cayFirstUpWithoutMargin (* 3 (/ Pi 2)) vi))
  327. (setq cayFirstUpWithMargin (polar cayFirstUpWithoutMargin (/ Pi 2) 30))
  328. (setq cayFirstDownWithMargin (polar cayFirstDownWithoutMargin (/ Pi 2) -30))
  329. (command "_line" cayFirstUpWithMargin cayFirstDownWithMargin "")
  330.  
  331. (setq caySecondUpWithoutMargin (polar c1 0 (/ sh 2)))
  332. (setq caySecondDownWithoutMargin (polar caySecondUpWithoutMargin (* 3 (/ Pi 2)) vi))
  333. (setq caySecondUpWithMargin (polar caySecondUpWithoutMargin (/ Pi 2) 30))
  334. (setq caySecondDownWithMargin (polar caySecondDownWithoutMargin (/ Pi 2) -30))
  335. (command "_line" caySecondUpWithMargin caySecondDownWithMargin "")
  336. )
  337. ; Input data
  338. (setq
  339. p1 (GetPoint " Ââåäèòå íà÷àëüíûå êîîðäèíàòû ")
  340. x (nth 0 p1)
  341. y (nth 1 p1)
  342. )
  343. (setq dl (GetReal "\nÂâåäèòå dl (70): "))
  344. (if (= dl nil)
  345. (progn (setq dl 70))
  346. )
  347. (setq sh (GetReal "\nÂâåäèòå sh (35): "))
  348. (if (= sh nil)
  349. (progn (setq sh 35))
  350. )
  351. (setq vi (GetReal "\nÂâåäèòå vi (34): "))
  352. (if (= vi nil)
  353. (progn (setq vi 34))
  354. )
  355. (setq shkv1 (GetReal "\nÂâåäèòå shkv1 (16): "))
  356. (if (= shkv1 nil)
  357. (progn (setq shkv1 16))
  358. )
  359. (setq shkv2 (GetReal "\nÂâåäèòå shkv2 (24): "))
  360. (if (= shkv2 nil)
  361. (progn (setq shkv2 24))
  362. )
  363. (setq dlvn (GetReal "\nÂâåäèòå dlvn (56): "))
  364. (if (= dlvn nil)
  365. (progn (setq dlvn 56))
  366. )
  367. (drawAll p1 sh vi shkv1 shkv2 dlvn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement