机械社区

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

作者: laotoule8    时间: 2025-2-7 09:55
标题: 还有哪些例子可以用DEEPSEEK帮助CAD绘图的?
用了deepseek写的VBA代码用在CAD,挺好用的。有没有其他的方便CAD使用的deepseek的例子推荐一下?/ X) z' D2 _  }- _) g5 J
  1. Sub AddRectangleAndArrayAndTrim()
    : w/ y- p$ T* K# ~( q. |1 N- t
  2.     ' 声明变量
    9 b* I! U3 J* D4 C7 I
  3.     Dim lineObj As Object, @& F- R3 S  i& G4 P* j
  4.     Dim startPoint As Variant
    ; q+ M! S# O+ P  P; a8 r2 b5 s
  5.     Dim endPoint As Variant
    , A% P5 J& o$ H9 X& s, i
  6.     Dim rectWidth As Double
    $ w) |* a1 s- I9 C
  7.     Dim rectHeight As Double
    " d5 ?0 b/ ]8 m, l; M1 A
  8.     Dim rectStartPoint(0 To 2) As Double5 @3 u3 B  N+ D$ j! g# h
  9.     Dim rectEndPoint(0 To 2) As Double3 _) C. v. V4 O6 m, D) R2 Q
  10.     Dim rotationAngle As Double
    ; {% a2 ]  O/ g) Z4 d5 Z8 }; T
  11.     Dim rectObj As Object2 ^5 W2 l3 S: o" _, k
  12.     Dim points(0 To 7) As Double ' 用于存储矩形的四个顶点
    , @. x; ~% h0 s& i; f
  13.     Dim centerPoint(0 To 2) As Double ' 直线的中点1 l% N" H1 _+ y) h) n
  14.     Dim newRectObj As Object ' 复制的矩形对象! U+ I2 V8 p/ v6 B/ g0 L) T  F
  15.     Dim rotationAngleRad As Double ' 旋转角度(弧度); L) X0 y8 v$ o- {
  16.     Dim intersectPoint As Variant ' 交点
    ! f2 C9 y" ]( ?& ?: I
  17.     Dim trimStartPoint As Variant ' 修剪后的起点
    % Y% a) y1 F5 E4 }8 ^
  18.     Dim trimEndPoint As Variant ' 修剪后的终点( L' I& ]* _4 J5 L2 L" f6 d
  19.     . e4 z. s2 T1 d3 [! A% K7 a
  20.     ' 定义矩形的尺寸
    / y5 v. f9 z9 q4 k
  21.     rectWidth = 0.1 ' 矩形的宽度(短边)1 Q7 |- Y3 Q+ H- u7 v
  22.     rectHeight = 1  ' 矩形的高度(长边)% k6 Q& K5 R. w$ ~2 W
  23.    
    ( k' L" F& B7 Y! g5 k' j& |
  24.     ' 提示用户选择一条直线
    # f  H% a$ e2 K. G# |5 j2 y5 D5 J; j
  25.     On Error Resume Next
    2 f* J8 X$ _! m5 l
  26.     ThisDrawing.Utility.GetEntity lineObj, startPoint, "请选择一条直线: "& W# o0 b" V! j9 D2 [$ Z
  27.     On Error GoTo 07 y4 a) R0 \0 C3 G
  28.    
    4 w/ h: |& o4 o0 m% M
  29.     ' 检查用户是否选择了直线
    # _: i3 c& c- I  k2 o0 K( c+ k
  30.     If lineObj Is Nothing Then$ E# r! G2 q5 f3 o8 d
  31.         MsgBox "未选择直线或选择无效。"5 E- n  g  ?" D; @( V; p
  32.         Exit Sub. N! h; C8 b$ e7 j2 {/ e, a/ {
  33.     End If
    # V3 j# B  I& n# t
  34.     % ?6 W; E5 ^5 {( G
  35.     ' 获取直线的起点和终点9 Q7 W7 k! `  j+ u$ h2 k
  36.     startPoint = lineObj.StartPoint3 X: @  Y; G' K9 P' D2 n7 K. w
  37.     endPoint = lineObj.EndPoint
    7 g; J, a, c) r8 K! G! k# e3 a& e4 \
  38.     # \; r! i3 r' g4 y
  39.     ' 计算直线的中点
    ' S4 c4 Y4 {. ~9 N
  40.     centerPoint(0) = (startPoint(0) + endPoint(0)) / 2
    + T: X+ K( t- r# Q: i
  41.     centerPoint(1) = (startPoint(1) + endPoint(1)) / 2
    $ T* J8 q) n* d1 z- K
  42.     centerPoint(2) = (startPoint(2) + endPoint(2)) / 2
    , Q" i' J6 E+ Y
  43.     7 L- h% Z. ^8 p; X2 p' B9 H+ Z3 I
  44.     ' 计算直线的角度(用于矩形的旋转)
    # G9 [# f: j7 }8 N1 ^8 [) R
  45.     rotationAngle = Atn((endPoint(1) - startPoint(1)) / (endPoint(0) - startPoint(0)))
    7 g4 v: V2 T4 }
  46.     8 X% G1 J, ^. g; V/ M; q1 Y* q
  47.     ' 计算矩形的起点和终点
    ( p! p" `7 Q% D3 \% @7 Q( Q
  48.     rectStartPoint(0) = startPoint(0) - (rectWidth / 2) * Cos(rotationAngle + (3.14159 / 2))
    . W5 w9 F+ @5 D. {, w
  49.     rectStartPoint(1) = startPoint(1) - (rectWidth / 2) * Sin(rotationAngle + (3.14159 / 2))0 v) q5 b6 ~/ [- ^6 f1 t
  50.     rectStartPoint(2) = startPoint(2)
    - O7 u* N. E5 g& i# w
  51.    
    % O3 s# {) b- k. N0 t
  52.     rectEndPoint(0) = rectStartPoint(0) + rectHeight * Cos(rotationAngle)
    1 ]% v8 Z' v2 P+ I" v
  53.     rectEndPoint(1) = rectStartPoint(1) + rectHeight * Sin(rotationAngle)( d- C* r+ ]. ]1 w
  54.     rectEndPoint(2) = rectStartPoint(2)
    3 H6 w3 i, l; s, i
  55.       d- b! d9 ^# a/ ^
  56.     ' 定义矩形的四个顶点
    - c  o) Y" s" Y/ w
  57.     points(0) = rectStartPoint(0)* y2 @( @! O. F, @1 b9 O% l/ l4 m
  58.     points(1) = rectStartPoint(1)
    % |$ g/ b7 L" e% Z2 G4 e
  59.     points(2) = rectEndPoint(0)+ j: o  O$ J- m; V6 n8 u: T; F
  60.     points(3) = rectEndPoint(1)2 k* v2 R/ H+ c. g
  61.     points(4) = rectEndPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))" {4 d( l' \/ a5 i. x% B0 [$ i
  62.     points(5) = rectEndPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))4 E8 Q' Y2 u$ Q- h
  63.     points(6) = rectStartPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))9 Y4 ~! H' {. c, l% }! Z1 W4 P1 c
  64.     points(7) = rectStartPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))+ f6 s) r. y& k( b  `
  65.    
    & f$ u5 W( I4 f% u2 ?( t
  66.     ' 创建矩形
      S" h5 L& `% D/ B9 q7 W
  67.     Set rectObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)8 @3 _# B* X0 U4 r0 f
  68.     ' u: B7 \& w5 a) z7 e  |5 S
  69.     ' 创建圆周阵列(手动复制和旋转): q) f2 }2 a2 z" J& V# J
  70.     rotationAngleRad = 180 * (3.14159 / 180) ' 将角度转换为弧度# ]1 c* M7 D/ ~: `& K" x
  71.     Set newRectObj = rectObj.Copy3 Z$ I2 m. C& M+ t7 c, v0 R
  72.     newRectObj.Rotate centerPoint, rotationAngleRad0 N# \# {7 k. z( A" {+ _3 l. W7 d- a  W
  73.     ; \& K, G6 V, F" o
  74.     ' 修剪直线5 H$ \$ l" {8 F! N* H8 M
  75.     ' 查找直线与矩形的交点
      x; J9 B6 ?: `# x) f" f
  76.     intersectPoint = lineObj.IntersectWith(rectObj, acExtendNone)2 ]7 k2 R% @! O  y3 l7 t
  77.     If Not IsEmpty(intersectPoint) Then
    6 Z: L* \6 c4 s6 ~5 W
  78.         ' 修剪直线的起点
    ) I" U& @9 W  B: m4 M
  79.         trimStartPoint = intersectPoint
    . ^3 }3 t5 c6 S; m
  80.         lineObj.StartPoint = trimStartPoint
    ( g$ n6 P. p+ V& G5 O# C
  81.     End If# r! b7 B* \& Z$ v# W
  82.    
    ( `' W7 Y% d/ t: q
  83.     intersectPoint = lineObj.IntersectWith(newRectObj, acExtendNone): \8 l$ g4 q9 d" \
  84.     If Not IsEmpty(intersectPoint) Then
    7 I, ]' Q( a2 t! s- {8 r: k4 `- v
  85.         ' 修剪直线的终点& e( A- S  N: J
  86.         trimEndPoint = intersectPoint
    & Y' F- x; A* }9 b; N
  87.         lineObj.EndPoint = trimEndPoint
    2 l5 k: o: ^  v; D! S: I
  88.     End If# j/ K! t5 n7 C: c4 J; s
  89.    
    $ h1 Y3 |( j3 S5 P- w* f
  90.     ' 刷新视图
    , C6 p& R4 [; x( k8 R) x
  91.     ThisDrawing.Regen True
    8 S1 b3 x/ s" c
  92.    
    + H( D- q" s. U
  93.     ' 提示用户
    " O4 L; F# L% a$ G3 w5 t) {" g
  94.     MsgBox "矩形、阵列和修剪操作已完成!"
      K5 D3 Z  M' ^. ]5 ~7 D8 n2 n: C
  95. End Sub
复制代码

& {" ~6 {! c* p. w
6 U% P& T) i9 [7 }; v' c8 L
作者: 564156415gdr    时间: 2025-2-7 10:01
blender也可以。去年试过一次
作者: 学者11    时间: 2025-2-7 10:34
这叫脱裤子放屁,没有任何可行性。3 ^6 \) ^, s% p0 {7 ?
首先怎么保证AI模型的回答不会有幻觉,你保证不了。
$ i: y2 A0 K" ?% U其次怎么保证工程师能识别出AI模型的回答有幻觉,更保证不了,因为多数机械工程师不懂代码。" U4 d1 r  b& C" Q8 R2 k: B
最关键的是,AI模型根本不能直接控制CAD,还需要人手工把代码复制粘贴,CAD才会画图。
, `2 w( A* m5 L& q- d那请问为何不能直接让机械工程师直接画图,你既不能提高效率,又不能节省人工,这么骚操作的意义何在。
作者: kayex    时间: 2025-2-7 16:04
这个把简单的事情复杂化了
作者: 寰宇无人    时间: 2025-2-8 09:27
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂
% h8 V5 G; X8 ]) \" }
作者: 寰宇无人    时间: 2025-2-8 09:28
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂1 c0 q) Z; `1 }- G

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




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