明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 989|回复: 4

[建筑] 求一个可以画冷弯C型钢的插件。

[复制链接]
发表于 2024-5-26 10:12:35 | 显示全部楼层 |阅读模式
求一个可以画冷弯C型钢的插件。做金属屋经常用到
发表于 2024-5-26 10:18:40 | 显示全部楼层
标准品直接做动态块不香吗?
发表于 2024-5-26 10:45:17 | 显示全部楼层
  1. ;;;;绘制C型钢
  2. (defun c:cxg ( / h b c t1 pt0 pt0x pt0y pt0z pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8 pt9 pt10 pt11 pt12 pt13 pt14 pt15 pt16 pt17 pt18 pt19 pt20)
  3.   (princ "\n绘制C型钢")
  4.   (command "_.undo" "be")
  5.   (setvar "osmode" 0)
  6.   (setq h (getreal "\n请输入C型钢高度[200]:"))
  7.   (if (= h nil) (setq h 200))
  8.   (setq b (getreal "\n请输入C型钢宽度[70]:"))
  9.   (if (= b nil) (setq b 70))
  10.   (setq c (getreal "\n请输入C型钢卷边尺寸[20]:"))
  11.   (if (= c nil) (setq c 20))
  12.   (setq t1 (getreal "\n请输入C型钢厚度[2.0]:"))
  13.   (if (= t1 nil) (setq t1 2))
  14.   (setq pt0 (getpoint "\n请指定插入点:"))
  15.   (setq pt0x (car pt0))
  16.   (setq pt0y (cadr pt0))
  17.   (setq pt0z (caddr pt0))
  18.   (setq pt1 (list (- pt0x (/ b 2)) (+ pt0y (- (/ h 2) 8)) (+ pt0z 0)))
  19.   (setq pt2 (list (- pt0x (- (/ b 2) 8)) (+ pt0y (/ h 2)) (+ pt0z 0)))
  20.   (setq pt3 (list (+ pt0x (- (/ b 2) 8)) (+ pt0y (/ h 2)) (+ pt0z 0)))
  21.   (setq pt4 (list (+ pt0x (/ b 2)) (+ pt0y (- (/ h 2) 8)) (+ pt0z 0)))
  22.   (setq pt5 (list (+ pt0x (/ b 2)) (+ pt0y (- (/ h 2) c)) (+ pt0z 0)))
  23.   (setq pt6 (list (+ pt0x (- (/ b 2) t1)) (+ pt0y (- (/ h 2) c)) (+ pt0z 0)))
  24.   (setq pt7 (list (+ pt0x (- (/ b 2) t1)) (+ pt0y (- (/ h 2) 8)) (+ pt0z 0)))
  25.   (setq pt8 (list (+ pt0x (- (/ b 2) 8)) (+ pt0y (- (/ h 2) t1)) (+ pt0z 0)))
  26.   (setq pt9 (list (- pt0x (- (/ b 2) 8)) (+ pt0y (- (/ h 2) t1)) (+ pt0z 0)))
  27.   (setq pt10 (list (- pt0x (- (/ b 2) t1)) (+ pt0y (- (/ h 2) 8)) (+ pt0z 0)))
  28.   (setq pt11 (list (- pt0x (- (/ b 2) t1)) (- pt0y (- (/ h 2) 8)) (+ pt0z 0)))
  29.   (setq pt12 (list (- pt0x (- (/ b 2) 8)) (- pt0y (- (/ h 2) t1)) (+ pt0z 0)))
  30.   (setq pt13 (list (+ pt0x (- (/ b 2) 8)) (- pt0y (- (/ h 2) t1)) (+ pt0z 0)))
  31.   (setq pt14 (list (+ pt0x (- (/ b 2) t1)) (- pt0y (- (/ h 2) 8)) (+ pt0z 0)))
  32.   (setq pt15 (list (+ pt0x (- (/ b 2) t1)) (- pt0y (- (/ h 2) c)) (+ pt0z 0)))
  33.   (setq pt16 (list (+ pt0x (/ b 2)) (- pt0y (- (/ h 2) c)) (+ pt0z 0)))
  34.   (setq pt17 (list (+ pt0x (/ b 2)) (- pt0y (- (/ h 2) 8)) (+ pt0z 0)))
  35.   (setq pt18 (list (+ pt0x (- (/ b 2) 8)) (- pt0y (/ h 2)) (+ pt0z 0)))
  36.   (setq pt19 (list (- pt0x (- (/ b 2) 8)) (- pt0y (/ h 2)) (+ pt0z 0)))
  37.   (setq pt20 (list (- pt0x (/ b 2)) (- pt0y (- (/ h 2) 8)) (+ pt0z 0)))
  38.   (command "pline" pt6 "w" "0" "0" pt5 pt4 "a" "r" "8" pt3 "l" pt2  "a" "r" "8" pt1 "l" pt20  "a" "r" "8" pt19 "l" pt18 "a" "r" "8" pt17 "l" pt16 pt15 "")
  39.   (setq ename1 (entlast))
  40.   (command "pline" pt6 "w" "0" "0" pt7 "a" "r" "8" pt8 "l" pt9  "a" "r" "8" pt10 "l" pt11  "a" "r" "8" pt12 "l" pt13 "a" "r" "8" pt14 "l" pt15 pt16 "")
  41.   (setq ename2 (entlast))
  42.   (command "pedit" ename1 "j" ename2 "" "")
  43.   (setvar "osmode" 16383)
  44.   (command "_.undo" "e")
  45.   (princ)
  46. )


发表于 2024-5-26 12:32:41 | 显示全部楼层
  1.     '************************************************************************************************************************
  2.     '
  3.     '  11------10
  4.     '   | 6--7 |
  5.     '   | |  | |
  6.     '   | |  8-9  
  7.     '   | |
  8.     '   | |
  9.     '   | |  3-2
  10.     '   | |  | |
  11.     '   | 5--4 |
  12.     '   0------1

  13.     Function CXG(ByVal XH As String) As Entity
  14.         XH = XH.ToUpper.Replace("C", "")
  15.         Dim H As Double = Val(XH.Split("X")(0))
  16.         Dim B As Double = Val(XH.Split("X")(1))
  17.         Dim J As Double = Val(XH.Split("X")(2))
  18.         Dim T As Double = Val(XH.Split("X")(3))
  19.         Dim PtBase As Point3d = New Point3d(0, 0, 0)
  20.         Dim P0 As Point2d = New Point2d(PtBase(0), PtBase(1))
  21.         Dim P1 As Point2d = New Point2d(PtBase(0) + B, PtBase(1))
  22.         Dim P2 As Point2d = New Point2d(PtBase(0) + B, PtBase(1) + J)
  23.         Dim P3 As Point2d = New Point2d(PtBase(0) + B - T, PtBase(1) + J)
  24.         Dim P4 As Point2d = New Point2d(PtBase(0) + B - T, PtBase(1) + T)
  25.         Dim P5 As Point2d = New Point2d(PtBase(0) + T, PtBase(1) + T)
  26.         Dim P6 As Point2d = New Point2d(PtBase(0) + T, PtBase(1) + H - T)
  27.         Dim P7 As Point2d = New Point2d(PtBase(0) + B - T, PtBase(1) + H - T)
  28.         Dim P8 As Point2d = New Point2d(PtBase(0) + B - T, PtBase(1) + H - J)
  29.         Dim P9 As Point2d = New Point2d(PtBase(0) + B, PtBase(1) + H - J)
  30.         Dim P10 As Point2d = New Point2d(PtBase(0) + B, PtBase(1) + H)
  31.         Dim P11 As Point2d = New Point2d(PtBase(0), PtBase(1) + H)
  32.         Dim PL As AcDbs.Polyline = New AcDbs.Polyline
  33.         PL.AddVertexAt(0, P0, 0, 0, 0)
  34.         PL.AddVertexAt(1, P1, 0, 0, 0)
  35.         PL.AddVertexAt(2, P2, 0, 0, 0)
  36.         PL.AddVertexAt(3, P3, 0, 0, 0)
  37.         PL.AddVertexAt(4, P4, 0, 0, 0)
  38.         PL.AddVertexAt(5, P5, 0, 0, 0)
  39.         PL.AddVertexAt(6, P6, 0, 0, 0)
  40.         PL.AddVertexAt(7, P7, 0, 0, 0)
  41.         PL.AddVertexAt(8, P8, 0, 0, 0)
  42.         PL.AddVertexAt(9, P9, 0, 0, 0)
  43.         PL.AddVertexAt(10, P10, 0, 0, 0)
  44.         PL.AddVertexAt(11, P11, 0, 0, 0)
  45.         PL.Closed = True
  46.         TcApp.TcFuns.CAD.AddEnt(PL)
  47.         CXG = PL
  48.     End Function

  49.     '  7------6
  50.     '  |10-11 |
  51.     '  | |  | |
  52.     '  8-9  | |   
  53.     '       | |
  54.     '       | |
  55.     '       | |  3-2
  56.     '       | |  | |
  57.     '       | 5--4 |
  58.     '       0------1

  59.     Function ZXG(ByVal XH As String) As Entity
  60.         XH = XH.ToUpper.Replace("XZ", "")
  61.         Dim H As Double = Val(XH.Split("X")(0))
  62.         Dim B As Double = Val(XH.Split("X")(1))
  63.         Dim J As Double = Val(XH.Split("X")(2))
  64.         Dim T As Double = Val(XH.Split("X")(3))
  65.         Dim PtBase As Point3d = New Point3d(0, 0, 0)
  66.         Dim P0 As Point2d = New Point2d(PtBase(0), PtBase(1))
  67.         Dim P1 As Point2d = New Point2d(PtBase(0) + B, PtBase(1))
  68.         Dim P2 As Point2d = New Point2d(PtBase(0) + B, PtBase(1) + J)
  69.         Dim P3 As Point2d = New Point2d(PtBase(0) + B - T, PtBase(1) + J)
  70.         Dim P4 As Point2d = New Point2d(PtBase(0) + B - T, PtBase(1) + T)
  71.         Dim P5 As Point2d = New Point2d(PtBase(0) + T, PtBase(1) + T)
  72.         Dim P6 As Point2d = New Point2d(PtBase(0) + T, PtBase(1) + H)
  73.         Dim P7 As Point2d = New Point2d(PtBase(0) + T - B, PtBase(1) + H)
  74.         Dim P8 As Point2d = New Point2d(PtBase(0) + T - B, PtBase(1) + H - J)
  75.         Dim P9 As Point2d = New Point2d(PtBase(0) + T - B + T, PtBase(1) + H - J)
  76.         Dim P10 As Point2d = New Point2d(PtBase(0) + T - B + T, PtBase(1) + H - T)
  77.         Dim P11 As Point2d = New Point2d(PtBase(0), PtBase(1) + H - T)
  78.         Dim PL As AcDbs.Polyline = New AcDbs.Polyline
  79.         PL.AddVertexAt(0, P0, 0, 0, 0)
  80.         PL.AddVertexAt(1, P1, 0, 0, 0)
  81.         PL.AddVertexAt(2, P2, 0, 0, 0)
  82.         PL.AddVertexAt(3, P3, 0, 0, 0)
  83.         PL.AddVertexAt(4, P4, 0, 0, 0)
  84.         PL.AddVertexAt(5, P5, 0, 0, 0)
  85.         PL.AddVertexAt(6, P6, 0, 0, 0)
  86.         PL.AddVertexAt(7, P7, 0, 0, 0)
  87.         PL.AddVertexAt(8, P8, 0, 0, 0)
  88.         PL.AddVertexAt(9, P9, 0, 0, 0)
  89.         PL.AddVertexAt(10, P10, 0, 0, 0)
  90.         PL.AddVertexAt(11, P11, 0, 0, 0)
  91.         PL.Closed = True
  92.         TcApp.TcFuns.CAD.AddEnt(PL)
  93.         ZXG = PL
  94.     End Function
发表于 2024-5-26 20:59:27 来自手机 | 显示全部楼层
探索者里面有绘制型钢,用起来还挺方便的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 16:04 , Processed in 0.648928 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表