机械社区

标题: 还有哪些例子可以用DEEPSEEK帮助CAD绘图的? [打印本页]

作者: laotoule8    时间: 2025-2-7 09:55
标题: 还有哪些例子可以用DEEPSEEK帮助CAD绘图的?
用了deepseek写的VBA代码用在CAD,挺好用的。有没有其他的方便CAD使用的deepseek的例子推荐一下?
" u) i* N* q  R- p9 m
  1. Sub AddRectangleAndArrayAndTrim()6 F% v4 v7 [( y3 f" Q+ }
  2.     ' 声明变量6 I7 c% m+ C! K% [  X8 D
  3.     Dim lineObj As Object
      e) U2 E+ Q7 E3 r
  4.     Dim startPoint As Variant
    5 {+ V% @) U5 u+ I+ r( M9 n) M! Y
  5.     Dim endPoint As Variant. i  A- B" y6 n$ [* N, E
  6.     Dim rectWidth As Double
    & t% P6 {9 z0 Z
  7.     Dim rectHeight As Double  X3 K2 x: g9 B; h- [5 f
  8.     Dim rectStartPoint(0 To 2) As Double
    $ z& N& l* D" N) D& j
  9.     Dim rectEndPoint(0 To 2) As Double
    : {+ K/ g5 U9 i8 B0 {1 Z  K8 T
  10.     Dim rotationAngle As Double3 ?  I, z% @  N# X, ^5 n1 {
  11.     Dim rectObj As Object
    5 }1 D3 T& b- K0 V* I
  12.     Dim points(0 To 7) As Double ' 用于存储矩形的四个顶点
    8 p  Y) c, @* L, y4 f
  13.     Dim centerPoint(0 To 2) As Double ' 直线的中点4 j( l9 G: y. d7 ^3 O* f! S
  14.     Dim newRectObj As Object ' 复制的矩形对象
    0 i2 {" w6 U' S" O& G( m$ b
  15.     Dim rotationAngleRad As Double ' 旋转角度(弧度)
    , q* {+ |) _) C
  16.     Dim intersectPoint As Variant ' 交点
    ; u# L5 u7 `" t9 `6 O
  17.     Dim trimStartPoint As Variant ' 修剪后的起点5 i! X* x: L+ v  y
  18.     Dim trimEndPoint As Variant ' 修剪后的终点. h+ y6 o$ j4 Z! C: m% M6 ~5 r
  19.    
    * f- t. _3 H: V, P; k3 a+ I) C8 Z
  20.     ' 定义矩形的尺寸
    ' V1 i6 h. b0 a" r, m# _
  21.     rectWidth = 0.1 ' 矩形的宽度(短边)* Q5 C8 F6 [3 o8 f
  22.     rectHeight = 1  ' 矩形的高度(长边)
    ; B8 G! l/ I' H3 {. v( R3 n8 L$ W! I
  23.     ( [1 m0 L7 A8 P  r
  24.     ' 提示用户选择一条直线) U$ E& [6 J0 d+ _0 {& Q  x3 w* D1 o
  25.     On Error Resume Next2 H0 ~4 T3 e' L& Z, |$ r, w5 Y
  26.     ThisDrawing.Utility.GetEntity lineObj, startPoint, "请选择一条直线: "( A0 \1 F+ n3 J. w6 `4 Q6 V/ R
  27.     On Error GoTo 0
    - S! {( I: p' ?4 s1 f3 Z+ z
  28.    
    1 G5 |& j" z3 z' {2 Q, a" ?
  29.     ' 检查用户是否选择了直线8 M7 l) B6 ?( }5 Z9 A9 V
  30.     If lineObj Is Nothing Then0 w& G6 ]$ e" W) }& O1 T
  31.         MsgBox "未选择直线或选择无效。"& O2 a2 k3 N& p4 R4 i
  32.         Exit Sub  T2 T% G) u# Q- p
  33.     End If
    # ?) J3 ?2 j: ^2 _* ?3 u
  34.     2 |8 B8 x1 |. }" O
  35.     ' 获取直线的起点和终点
    2 U1 `& O4 o. W" L
  36.     startPoint = lineObj.StartPoint
    4 j2 _: j1 w# h" l
  37.     endPoint = lineObj.EndPoint
    $ i$ \$ K( u+ O2 a
  38.     , `; w8 {0 c+ G; m, j
  39.     ' 计算直线的中点
    4 ^8 f0 Z" d( p; K+ o) S/ F
  40.     centerPoint(0) = (startPoint(0) + endPoint(0)) / 25 l) h7 o  |* }% v) k
  41.     centerPoint(1) = (startPoint(1) + endPoint(1)) / 22 _% e+ T! N. R" {
  42.     centerPoint(2) = (startPoint(2) + endPoint(2)) / 24 A! \) `- v. S: V3 r
  43.     $ A0 P& w) \) V1 `% h: O
  44.     ' 计算直线的角度(用于矩形的旋转)
    ) I! @8 M7 b5 w
  45.     rotationAngle = Atn((endPoint(1) - startPoint(1)) / (endPoint(0) - startPoint(0)))& N9 b: G( a2 L. y- u9 ~9 U6 v& }% q, |
  46.    
    ' W0 _$ c) D: z/ L' \) x4 {% T) E! {
  47.     ' 计算矩形的起点和终点
    ' D9 P$ Q" L6 |6 w+ N3 m7 D
  48.     rectStartPoint(0) = startPoint(0) - (rectWidth / 2) * Cos(rotationAngle + (3.14159 / 2))
    5 t3 V! z% F0 k* F+ C# ]
  49.     rectStartPoint(1) = startPoint(1) - (rectWidth / 2) * Sin(rotationAngle + (3.14159 / 2))
    1 A6 g/ ~7 n/ \1 d! v% V
  50.     rectStartPoint(2) = startPoint(2)& @& w, R8 ^) i+ E3 u0 X$ m- X
  51.    
    9 [9 U. A) W  }. G
  52.     rectEndPoint(0) = rectStartPoint(0) + rectHeight * Cos(rotationAngle)  {  L; U. I; W/ o
  53.     rectEndPoint(1) = rectStartPoint(1) + rectHeight * Sin(rotationAngle)
    / K7 I8 _  c* f$ e  g, w& X
  54.     rectEndPoint(2) = rectStartPoint(2)
    0 o! p1 p7 X6 v
  55.     , S  ]! x0 }$ c0 G! }9 L
  56.     ' 定义矩形的四个顶点" g- q0 V0 {7 c
  57.     points(0) = rectStartPoint(0)
    * S7 ~/ a  R0 G- W0 [" w
  58.     points(1) = rectStartPoint(1)
    0 @. q7 L/ Y8 Y
  59.     points(2) = rectEndPoint(0); T! M9 n8 [" n/ G
  60.     points(3) = rectEndPoint(1)% L$ ?2 o0 g9 k+ n6 s0 j0 t
  61.     points(4) = rectEndPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))
    $ `5 F* A  y* z! W% C  c
  62.     points(5) = rectEndPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))
    6 K) B. d3 C* q7 N; X! d# T2 M! g
  63.     points(6) = rectStartPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))0 m: t( x- w8 q0 Z+ H$ |: J( F
  64.     points(7) = rectStartPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))
    ! L( |8 h9 Q' G& d5 H3 A6 I  J
  65.    
    8 p2 `0 D9 z1 k  B" e% u5 s
  66.     ' 创建矩形
    6 ~) k8 R; {/ |, I! B
  67.     Set rectObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    $ W+ i% i% C, U/ T! q
  68.    
    ; ~# k$ R  C: W" T9 P/ |
  69.     ' 创建圆周阵列(手动复制和旋转)1 ?' V) f5 k$ R5 _# ^  L# i
  70.     rotationAngleRad = 180 * (3.14159 / 180) ' 将角度转换为弧度& B' A, `1 g! d( |2 d' s
  71.     Set newRectObj = rectObj.Copy  @1 J* q$ E. M9 o2 U9 p
  72.     newRectObj.Rotate centerPoint, rotationAngleRad1 ?, c4 U3 C  y4 n" X5 F) l
  73.     2 q. M$ q1 T/ X# @
  74.     ' 修剪直线6 n2 ?$ v4 `0 O
  75.     ' 查找直线与矩形的交点
    / b# }/ Q( G" s: p$ t
  76.     intersectPoint = lineObj.IntersectWith(rectObj, acExtendNone)
    . @3 e  ^1 Y1 X0 L7 s! r1 c  j/ Z
  77.     If Not IsEmpty(intersectPoint) Then% H+ f2 s, T  l9 x4 @6 F  m2 u" Y
  78.         ' 修剪直线的起点$ p+ }" y% ]& K2 ]
  79.         trimStartPoint = intersectPoint( s* I0 z) Q& G
  80.         lineObj.StartPoint = trimStartPoint
    ; z3 ~! C6 ]% y( Z% U
  81.     End If# a9 D8 W7 G7 S
  82.     ) x# _9 U: t. j8 {
  83.     intersectPoint = lineObj.IntersectWith(newRectObj, acExtendNone)2 [: T. [; _8 v7 E7 V2 s! O5 A$ ~
  84.     If Not IsEmpty(intersectPoint) Then3 a! I3 W6 H! N0 H
  85.         ' 修剪直线的终点' |3 A0 B0 o! V9 n9 ^% J$ F( k/ @. L
  86.         trimEndPoint = intersectPoint
      i4 W$ l" k' O, [; |8 @0 W6 y
  87.         lineObj.EndPoint = trimEndPoint% v5 y! O9 L8 }9 {" ~
  88.     End If1 ~! G$ l  w) c4 g4 }7 w. q
  89.     : ?& j( l0 Y& s2 {( z
  90.     ' 刷新视图1 j0 e5 }& r/ j3 j/ E$ C+ \1 ?
  91.     ThisDrawing.Regen True% W5 Y. V0 F, A$ c0 p- C$ Q
  92.     ) Q2 S( _, ~$ `  ]8 Q
  93.     ' 提示用户3 ?4 d5 s# M! {
  94.     MsgBox "矩形、阵列和修剪操作已完成!". B. X9 ~# i5 _5 x% J# O( W7 e1 U7 `
  95. End Sub
复制代码
  m3 o+ m# z+ Q. ]

1 B" R; R- b; G/ c9 [1 H# M
作者: 564156415gdr    时间: 2025-2-7 10:01
blender也可以。去年试过一次
作者: 学者11    时间: 2025-2-7 10:34
这叫脱裤子放屁,没有任何可行性。
8 c2 a0 \" z0 Z8 R) G$ E首先怎么保证AI模型的回答不会有幻觉,你保证不了。  k, d6 ?* z# S; i2 N" \! D  w
其次怎么保证工程师能识别出AI模型的回答有幻觉,更保证不了,因为多数机械工程师不懂代码。
" E0 u- h- i5 E. F最关键的是,AI模型根本不能直接控制CAD,还需要人手工把代码复制粘贴,CAD才会画图。
: m9 b7 z2 a& q. k* _那请问为何不能直接让机械工程师直接画图,你既不能提高效率,又不能节省人工,这么骚操作的意义何在。
作者: kayex    时间: 2025-2-7 16:04
这个把简单的事情复杂化了
作者: 寰宇无人    时间: 2025-2-8 09:27
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂; W. t9 |( d/ Q8 d

作者: 寰宇无人    时间: 2025-2-8 09:28
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂, H+ ?9 l3 X5 g7 t) W: x# e

作者: 寰宇无人    时间: 2025-2-8 09:29
想让他直接出图,标注尺寸,公差,工艺这些,还得大量模型喂他,不过未来的智能化发展,谁能说的准呢
作者: zhl6200    时间: 2025-2-18 12:19
我直接给定齿轮参数,让deepseek画齿轮零件图,它明确回答我,他没有此功能,只给出了画图思路,也许以后会实现。




欢迎光临 机械社区 (http://www.cmiw.cn/) Powered by Discuz! X3.5