机械社区

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

作者: laotoule8    时间: 2025-2-7 09:55
标题: 还有哪些例子可以用DEEPSEEK帮助CAD绘图的?
用了deepseek写的VBA代码用在CAD,挺好用的。有没有其他的方便CAD使用的deepseek的例子推荐一下?' _& Q, @" k/ S$ W2 @% P& o/ k
  1. Sub AddRectangleAndArrayAndTrim()& a' F2 y, q+ L' J9 F, B
  2.     ' 声明变量
    # y- t7 N& m: t
  3.     Dim lineObj As Object
    2 [3 N. J+ Y8 @" W7 P
  4.     Dim startPoint As Variant8 r6 J( `% `$ q0 u
  5.     Dim endPoint As Variant
    ' ^! ?" z7 [. K$ n+ l
  6.     Dim rectWidth As Double/ |8 I- D( A5 F+ G2 k+ w. [1 h0 T
  7.     Dim rectHeight As Double
    $ R2 `+ _7 k  c3 H+ [8 l% m
  8.     Dim rectStartPoint(0 To 2) As Double3 Z8 I0 g5 F" z3 u! w! V1 L  z
  9.     Dim rectEndPoint(0 To 2) As Double/ t+ a  ]3 l4 G0 H) F
  10.     Dim rotationAngle As Double
    1 O: a9 Q: Q- b9 d- I* ?& ^/ P; A+ [
  11.     Dim rectObj As Object
    7 X( K# H8 B% |  \* W
  12.     Dim points(0 To 7) As Double ' 用于存储矩形的四个顶点' ]# M5 X3 t7 i: J: t7 C6 _! o3 y
  13.     Dim centerPoint(0 To 2) As Double ' 直线的中点
    ; D7 i3 F7 @  g% Q/ U  @( ?7 B6 u/ O
  14.     Dim newRectObj As Object ' 复制的矩形对象
    " h5 r3 @) H" ~; L
  15.     Dim rotationAngleRad As Double ' 旋转角度(弧度)7 R4 c" M- J5 F$ l7 ?4 L
  16.     Dim intersectPoint As Variant ' 交点
    + F, M) p" p- I. N! Z
  17.     Dim trimStartPoint As Variant ' 修剪后的起点
    , p% `- i' e& j7 L. |- s/ S+ F. h
  18.     Dim trimEndPoint As Variant ' 修剪后的终点
    0 ]" Z. B" d  \4 \6 X( o( z& m+ g
  19.    
    $ p  W% \1 e4 Z# n% p5 O
  20.     ' 定义矩形的尺寸
    , F  e3 Q! o6 ^0 m
  21.     rectWidth = 0.1 ' 矩形的宽度(短边)
    8 y% ~7 h; I6 `2 w0 c9 k
  22.     rectHeight = 1  ' 矩形的高度(长边), d- S9 N# r/ z: o; H6 h
  23.     ; F. d3 x/ r( j1 W% o4 a# x
  24.     ' 提示用户选择一条直线
    7 J2 ^5 l4 V& @# M3 H; d
  25.     On Error Resume Next
    : V7 X5 m& S+ N& `
  26.     ThisDrawing.Utility.GetEntity lineObj, startPoint, "请选择一条直线: "/ \# W0 ^. M; S' s
  27.     On Error GoTo 09 {, @" G% }3 }% j# U  L
  28.     . D. Q1 L8 w0 b5 N9 k
  29.     ' 检查用户是否选择了直线
    6 Z- a% p, W4 X. ^% _  _6 u
  30.     If lineObj Is Nothing Then# M: W2 ]7 R% Q  c9 c
  31.         MsgBox "未选择直线或选择无效。". ~0 J# V$ T. O9 Q6 X$ N, J
  32.         Exit Sub' h# I/ }) A$ S1 M
  33.     End If
    3 t/ i! m  N7 m- t, m
  34.     6 L" K( v! `/ N# `
  35.     ' 获取直线的起点和终点* S- q7 i4 q  [5 E2 P9 R( N1 W% i$ i
  36.     startPoint = lineObj.StartPoint
    4 S4 m7 e# ]5 m) ?! v5 L
  37.     endPoint = lineObj.EndPoint' Z; t6 A2 N3 W4 _
  38.    
    ) M8 v0 j* M1 Q$ S& e9 y5 }0 R9 [$ K
  39.     ' 计算直线的中点! D2 ?7 _9 s' F8 v
  40.     centerPoint(0) = (startPoint(0) + endPoint(0)) / 2) O% I. C8 S9 o; M; [- ]2 f# K/ K' }
  41.     centerPoint(1) = (startPoint(1) + endPoint(1)) / 2
    - v3 ^% v* Z2 t  S( H
  42.     centerPoint(2) = (startPoint(2) + endPoint(2)) / 2
    ; E  x8 C* o- v. k
  43.    
    0 @2 @$ O+ u) N) t
  44.     ' 计算直线的角度(用于矩形的旋转)
    - r$ }& m4 h, d6 A0 N8 J& p
  45.     rotationAngle = Atn((endPoint(1) - startPoint(1)) / (endPoint(0) - startPoint(0)))
    # H* ?# ^4 G/ \  J1 q4 A5 ]
  46.     1 F$ A4 G# \1 i3 q
  47.     ' 计算矩形的起点和终点
    8 J: N+ ^7 t4 W( D" G% g
  48.     rectStartPoint(0) = startPoint(0) - (rectWidth / 2) * Cos(rotationAngle + (3.14159 / 2))# B2 r! ]8 w9 Z
  49.     rectStartPoint(1) = startPoint(1) - (rectWidth / 2) * Sin(rotationAngle + (3.14159 / 2))
    ' q6 U' x9 e- p( c5 o' T( |% q
  50.     rectStartPoint(2) = startPoint(2)& h6 G# p% u% G. W4 v  K: V5 j/ S' B
  51.    
    3 `. T( T/ Y& y# j8 a: y
  52.     rectEndPoint(0) = rectStartPoint(0) + rectHeight * Cos(rotationAngle)5 x+ N# ]# X6 v. X2 P' s
  53.     rectEndPoint(1) = rectStartPoint(1) + rectHeight * Sin(rotationAngle)  N* C+ `* Q' x/ D! j2 X, Q
  54.     rectEndPoint(2) = rectStartPoint(2)
    0 l" Q! M# R! W/ x
  55.     / Y* E7 u& w& G0 [7 [0 i: C
  56.     ' 定义矩形的四个顶点( D# @8 d& W& V1 k& j+ I5 D. O( q0 d
  57.     points(0) = rectStartPoint(0)
    % l+ d3 h  K6 s- j$ p3 M/ W
  58.     points(1) = rectStartPoint(1)$ z1 G. l6 g. Y
  59.     points(2) = rectEndPoint(0)
    0 f; u! q7 a! x
  60.     points(3) = rectEndPoint(1)) _' G$ K2 h/ W' B" z% @# d
  61.     points(4) = rectEndPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))
    & L+ ?) a6 e/ K7 |$ j
  62.     points(5) = rectEndPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2)); k: j8 c5 Z/ x5 R6 L- H
  63.     points(6) = rectStartPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))
    % ]- d2 R0 y/ M( y
  64.     points(7) = rectStartPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))
    4 Q6 d: J! u8 K' x9 D
  65.     0 ]* {; F) S$ O$ h6 ?
  66.     ' 创建矩形
    - P; P8 _: D5 p6 Z% b& f) y# `7 {
  67.     Set rectObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    1 z' i2 G0 a) i. j" g% ~6 a
  68.    
    " |; o4 m- u4 [; J& F' b' E
  69.     ' 创建圆周阵列(手动复制和旋转)
    $ z7 k; z0 u! }/ s3 Q8 v6 W0 u
  70.     rotationAngleRad = 180 * (3.14159 / 180) ' 将角度转换为弧度
    4 q/ K9 ?! z# [/ W' Z3 j
  71.     Set newRectObj = rectObj.Copy% o3 I8 J, O) ~/ g# p
  72.     newRectObj.Rotate centerPoint, rotationAngleRad
    1 I* x0 u  M, a9 c& Q6 [
  73.    
    - [3 L, j* `6 J9 L8 F8 f8 ^4 z
  74.     ' 修剪直线
    * [1 ^1 ^# w  Q& V8 _
  75.     ' 查找直线与矩形的交点% t5 F, {& p# s3 H6 y$ D; @3 X
  76.     intersectPoint = lineObj.IntersectWith(rectObj, acExtendNone)3 {; ?1 H2 R; d5 ~
  77.     If Not IsEmpty(intersectPoint) Then
    9 g7 q5 y7 u( V, o+ ^' p1 J) R2 M
  78.         ' 修剪直线的起点) W6 Q2 J" \$ y5 U; e1 p7 \
  79.         trimStartPoint = intersectPoint
    . N( ]) O. g. z, ?
  80.         lineObj.StartPoint = trimStartPoint
      o- ^9 J8 ^5 k
  81.     End If
    : f' {! _4 c! ]; M" J( U7 j- C; V
  82.     0 q* L7 c. [3 e( N. A; B
  83.     intersectPoint = lineObj.IntersectWith(newRectObj, acExtendNone)- S: n9 g: }* s
  84.     If Not IsEmpty(intersectPoint) Then5 L; x! _% _( Y; J' D, M- K
  85.         ' 修剪直线的终点; Y' d2 I0 P, d3 b, o
  86.         trimEndPoint = intersectPoint
    $ G8 C8 x9 {9 x6 m( Y; _
  87.         lineObj.EndPoint = trimEndPoint
    ' P  H/ f% W2 s
  88.     End If: ^) f9 Q7 G% u, }# I# e+ {
  89.    
    7 C, J' i9 g& K7 L: Z- v. _( h' e
  90.     ' 刷新视图0 e0 ^' q$ l: i6 t$ [; b- i9 L
  91.     ThisDrawing.Regen True
    ) w- K* t/ h5 B" A0 L9 u
  92.     ' Z. X8 _5 |# }% \; g. V1 G: T
  93.     ' 提示用户
      O" j* U2 ]* }+ o8 h3 j( \+ n8 j
  94.     MsgBox "矩形、阵列和修剪操作已完成!"& K& o1 D  l$ ]6 u7 {& v3 W) Q
  95. End Sub
复制代码

; G& V8 n' y9 f3 ~, Y6 B, l+ l1 }  [1 K1 J6 F4 Y/ M) W

作者: 564156415gdr    时间: 2025-2-7 10:01
blender也可以。去年试过一次
作者: 学者11    时间: 2025-2-7 10:34
这叫脱裤子放屁,没有任何可行性。( z* e  z! |' f+ k8 \
首先怎么保证AI模型的回答不会有幻觉,你保证不了。' N  ]7 c7 Y  {# f3 Q/ Y* s4 z, h
其次怎么保证工程师能识别出AI模型的回答有幻觉,更保证不了,因为多数机械工程师不懂代码。
! i* N* Z. Q! L" t' [* i8 ~( F. |最关键的是,AI模型根本不能直接控制CAD,还需要人手工把代码复制粘贴,CAD才会画图。8 @# e& \1 s8 s9 r
那请问为何不能直接让机械工程师直接画图,你既不能提高效率,又不能节省人工,这么骚操作的意义何在。
作者: kayex    时间: 2025-2-7 16:04
这个把简单的事情复杂化了
作者: 寰宇无人    时间: 2025-2-8 09:27
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂" c1 B7 Q" n! i% Q0 Y$ ^8 R

作者: 寰宇无人    时间: 2025-2-8 09:28
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂
; `) n: a6 W6 l* V9 h2 u1 [. B
作者: 寰宇无人    时间: 2025-2-8 09:29
想让他直接出图,标注尺寸,公差,工艺这些,还得大量模型喂他,不过未来的智能化发展,谁能说的准呢
作者: zhl6200    时间: 2025-2-18 12:19
我直接给定齿轮参数,让deepseek画齿轮零件图,它明确回答我,他没有此功能,只给出了画图思路,也许以后会实现。




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