机械社区

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

作者: laotoule8    时间: 2025-2-7 09:55
标题: 还有哪些例子可以用DEEPSEEK帮助CAD绘图的?
用了deepseek写的VBA代码用在CAD,挺好用的。有没有其他的方便CAD使用的deepseek的例子推荐一下?
4 n" O- G% _" p. S
  1. Sub AddRectangleAndArrayAndTrim()$ \5 |8 R; O  i: N; |5 \
  2.     ' 声明变量- g( b, Q+ o  D( d) E2 v- A
  3.     Dim lineObj As Object8 I& A' q- v* p0 h2 f* U
  4.     Dim startPoint As Variant
    / e6 p8 W$ G9 B  E! F3 V
  5.     Dim endPoint As Variant( W5 k" u" ~( l) K
  6.     Dim rectWidth As Double
    : ?! ]; P, C: E& S; H  T
  7.     Dim rectHeight As Double" }2 J: }  n4 z6 T0 J- Y" O
  8.     Dim rectStartPoint(0 To 2) As Double
    7 i; c- ?/ N7 {. z/ V+ v
  9.     Dim rectEndPoint(0 To 2) As Double6 i- n/ Z* ?5 S- ^9 `) c% v
  10.     Dim rotationAngle As Double
    " D  F5 g7 ]9 I' P
  11.     Dim rectObj As Object
    - q8 x& x3 [; O) q
  12.     Dim points(0 To 7) As Double ' 用于存储矩形的四个顶点
    # S% J6 W6 c, z* O) I
  13.     Dim centerPoint(0 To 2) As Double ' 直线的中点
    9 E1 C1 L- v& U
  14.     Dim newRectObj As Object ' 复制的矩形对象
    $ _+ p# K( i+ \6 X% L# U
  15.     Dim rotationAngleRad As Double ' 旋转角度(弧度)- _1 `/ m& B9 o
  16.     Dim intersectPoint As Variant ' 交点
    & c0 }0 K0 i+ O9 Y
  17.     Dim trimStartPoint As Variant ' 修剪后的起点
    # X* b+ }! U4 j1 }
  18.     Dim trimEndPoint As Variant ' 修剪后的终点. x, A" ?6 Q" [$ M$ K; g/ E
  19.    
    # J5 @1 x; @. @, s$ P8 m+ t0 e
  20.     ' 定义矩形的尺寸+ f7 ~/ r5 C) P3 t
  21.     rectWidth = 0.1 ' 矩形的宽度(短边)  [7 J5 r" i& t# z( m8 g3 [. ]  B
  22.     rectHeight = 1  ' 矩形的高度(长边), R# @' v4 b; U/ t  d2 m- H
  23.    
    : |  e2 g) c. m( O% j
  24.     ' 提示用户选择一条直线
    $ C9 }, L) t: y! Q
  25.     On Error Resume Next" k* b8 n! G; ^, p7 z- l
  26.     ThisDrawing.Utility.GetEntity lineObj, startPoint, "请选择一条直线: "
    ! |- w8 J2 d' [/ [. ~
  27.     On Error GoTo 0
    : c, j: s% I* ]5 k4 H! I, e
  28.    
    & @1 d7 k# n2 z7 w8 s
  29.     ' 检查用户是否选择了直线
    ! ]2 V4 c0 Z, Q) _  _1 h
  30.     If lineObj Is Nothing Then: ~1 i" o$ L# J8 K
  31.         MsgBox "未选择直线或选择无效。"
    : w0 d0 y* ]( O: n. d
  32.         Exit Sub4 T* x) y5 B) ^- a) K+ f9 j4 ]
  33.     End If
      j' @6 }6 W' ]8 p
  34.    
    ; n$ o, v. c+ C, T: |) B) K% H
  35.     ' 获取直线的起点和终点
    6 Q8 l5 P( O& n1 A
  36.     startPoint = lineObj.StartPoint' I0 b0 ]) b3 M; G( M5 P8 F
  37.     endPoint = lineObj.EndPoint8 M: w1 X  _7 H9 t3 ]% }
  38.    
    6 `& @1 ~3 w& {: k! v
  39.     ' 计算直线的中点
    , s* _0 T0 F  T  E$ _$ ~2 D
  40.     centerPoint(0) = (startPoint(0) + endPoint(0)) / 24 B' P+ q, W& o6 R& w
  41.     centerPoint(1) = (startPoint(1) + endPoint(1)) / 2' s9 e; N$ P1 Z% ?) s
  42.     centerPoint(2) = (startPoint(2) + endPoint(2)) / 2- w/ _1 z; T: X! n: G: M
  43.    
    ! t: D1 B0 z- U% D: ?9 A
  44.     ' 计算直线的角度(用于矩形的旋转)6 U$ N# \1 r, Q+ W  h$ Q, n$ n
  45.     rotationAngle = Atn((endPoint(1) - startPoint(1)) / (endPoint(0) - startPoint(0)))
    # q  {0 c* Z) k3 D& E2 _. V
  46.    
    ( x& C7 g  u+ A$ q. E( T
  47.     ' 计算矩形的起点和终点
    2 x# J5 d$ H3 G7 ?1 q* ]. J
  48.     rectStartPoint(0) = startPoint(0) - (rectWidth / 2) * Cos(rotationAngle + (3.14159 / 2))" P: `( |0 D; [0 j/ N9 P
  49.     rectStartPoint(1) = startPoint(1) - (rectWidth / 2) * Sin(rotationAngle + (3.14159 / 2))0 f  s& P) I) N4 D9 n6 y: K
  50.     rectStartPoint(2) = startPoint(2)! {# ^5 v' k, k5 H9 E7 x
  51.     : X6 s" O9 v1 n3 C% k' p
  52.     rectEndPoint(0) = rectStartPoint(0) + rectHeight * Cos(rotationAngle)# _+ ~. s, G; g9 U2 E" j; }: f
  53.     rectEndPoint(1) = rectStartPoint(1) + rectHeight * Sin(rotationAngle)
    9 X3 I0 a, ?8 G" A7 K9 R
  54.     rectEndPoint(2) = rectStartPoint(2)
    / |5 I+ m* C. _3 Y; R, y* B4 A
  55.     9 Z( t5 U! v1 M3 s, ?
  56.     ' 定义矩形的四个顶点; C0 y0 B# X+ }8 I" G! H+ K
  57.     points(0) = rectStartPoint(0)0 ]# U2 u& ]3 Y2 D5 H  W
  58.     points(1) = rectStartPoint(1)
    ) u  c9 K! [, j1 j
  59.     points(2) = rectEndPoint(0)5 c  T7 _* g, t
  60.     points(3) = rectEndPoint(1)
    ' p7 V& e- b( C2 e. s9 g; `
  61.     points(4) = rectEndPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))
    ( O! s' u7 x5 o" {
  62.     points(5) = rectEndPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))7 ]  m# f* _/ c! a* p' O, {: [
  63.     points(6) = rectStartPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))! v$ a0 K+ S1 n. Z0 X4 P
  64.     points(7) = rectStartPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))  W! l: h  b# e& {2 c
  65.     8 V* [% e, L( m8 @
  66.     ' 创建矩形
    . t+ p* }% L  s7 x
  67.     Set rectObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)4 _, ~2 U6 g/ c# h
  68.     * G) i/ D  b/ Y1 \9 r; \
  69.     ' 创建圆周阵列(手动复制和旋转)1 a% }2 P& F; |" m( l6 b; t
  70.     rotationAngleRad = 180 * (3.14159 / 180) ' 将角度转换为弧度7 F- D* j( f( N6 E' S
  71.     Set newRectObj = rectObj.Copy7 M: ~: U" a9 C- _
  72.     newRectObj.Rotate centerPoint, rotationAngleRad) n7 n8 w) m2 \# g6 h1 a/ L$ Z
  73.     : X; u3 Q/ q$ }- \
  74.     ' 修剪直线3 n6 ?) j" m; n$ T
  75.     ' 查找直线与矩形的交点0 ~8 b9 L, `6 n/ o
  76.     intersectPoint = lineObj.IntersectWith(rectObj, acExtendNone)! x. i2 G( H7 o& P9 [7 R' g8 Q' H
  77.     If Not IsEmpty(intersectPoint) Then
    2 f3 C- I  `) L1 N5 R. q
  78.         ' 修剪直线的起点) p8 F" B- {# P" v9 d
  79.         trimStartPoint = intersectPoint6 \2 @( G' L. v& g2 A
  80.         lineObj.StartPoint = trimStartPoint
    " n$ e# S5 s/ b* n9 m, u+ x8 Y
  81.     End If% V: o" I6 ]) K9 Q
  82.     . i; b6 Z& V2 ~2 n$ ~% \6 b
  83.     intersectPoint = lineObj.IntersectWith(newRectObj, acExtendNone)! A0 J6 K$ h1 \2 `, x8 ^% C
  84.     If Not IsEmpty(intersectPoint) Then6 A* g: J/ r7 @' T
  85.         ' 修剪直线的终点. k$ H/ i, L0 r" {) g; H& W" z$ T
  86.         trimEndPoint = intersectPoint
    5 u) q* P! E6 a: P
  87.         lineObj.EndPoint = trimEndPoint) @) q) q3 ~# n9 v$ `8 v* A
  88.     End If4 U- o  N8 W$ p0 y" P, y2 I" V1 g, ?
  89.     9 H% [3 |8 l/ F7 ^6 g; A$ L# [# V
  90.     ' 刷新视图7 A2 ]0 ^4 u$ _+ A/ I2 _" l2 ]. Q
  91.     ThisDrawing.Regen True
    6 q; h) o! c' ?/ u( }9 ]
  92.     1 N5 d: `5 k  K
  93.     ' 提示用户* r  o# h$ M. ~$ A  K/ F) V
  94.     MsgBox "矩形、阵列和修剪操作已完成!"
    4 I4 ]: j$ W+ a* H
  95. End Sub
复制代码
7 I/ k& c( Q! L/ A% o! B  o( A
8 R# [% `4 K5 D5 D8 ]$ X* |3 L

作者: 564156415gdr    时间: 2025-2-7 10:01
blender也可以。去年试过一次
作者: 学者11    时间: 2025-2-7 10:34
这叫脱裤子放屁,没有任何可行性。: e1 S$ r$ z! O- _0 A, h' K
首先怎么保证AI模型的回答不会有幻觉,你保证不了。3 F  |' N% B# Y' r( V0 y$ _
其次怎么保证工程师能识别出AI模型的回答有幻觉,更保证不了,因为多数机械工程师不懂代码。
) b$ M$ {2 ]6 T# T/ e最关键的是,AI模型根本不能直接控制CAD,还需要人手工把代码复制粘贴,CAD才会画图。
+ p, N; r. z% V2 `& L& X% a" c那请问为何不能直接让机械工程师直接画图,你既不能提高效率,又不能节省人工,这么骚操作的意义何在。
作者: kayex    时间: 2025-2-7 16:04
这个把简单的事情复杂化了
作者: 寰宇无人    时间: 2025-2-8 09:27
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂
4 P1 e% y, ]) s* t
作者: 寰宇无人    时间: 2025-2-8 09:28
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂* g3 h0 q4 e/ z

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




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