机械社区

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 4406|回复: 9

还有哪些例子可以用DEEPSEEK帮助CAD绘图的?

[复制链接]
发表于 2025-2-7 09:55:16 | 显示全部楼层 |阅读模式
用了deepseek写的VBA代码用在CAD,挺好用的。有没有其他的方便CAD使用的deepseek的例子推荐一下?
: q, H$ u% n& G6 u& V7 R: O
  1. Sub AddRectangleAndArrayAndTrim()! {& B! A3 N) G* q2 C( e: S. N0 O
  2.     ' 声明变量* ]0 P% U7 S* f, K
  3.     Dim lineObj As Object
    5 F' t- m  R. H" J& x& o' ?7 a  n
  4.     Dim startPoint As Variant" l; z7 `) b# a5 p
  5.     Dim endPoint As Variant! f1 c6 J. _. E/ l+ Q; f
  6.     Dim rectWidth As Double
    9 v7 A0 ?$ C6 c4 V) U# L0 Z/ [
  7.     Dim rectHeight As Double! n, O; P8 {6 p0 v4 v+ ^
  8.     Dim rectStartPoint(0 To 2) As Double
    ; k" r( I0 m+ q6 `$ j
  9.     Dim rectEndPoint(0 To 2) As Double
    ! s% S, @- \$ e( d1 \
  10.     Dim rotationAngle As Double: e% c2 ^  Q. T' ~2 o# F+ j
  11.     Dim rectObj As Object3 B. T. S; W/ ?$ J
  12.     Dim points(0 To 7) As Double ' 用于存储矩形的四个顶点& [5 \% N' ~* T/ p# s
  13.     Dim centerPoint(0 To 2) As Double ' 直线的中点) X& w0 V; y8 g$ ^) ]8 G
  14.     Dim newRectObj As Object ' 复制的矩形对象3 t4 ?' N9 J$ E+ I% Z
  15.     Dim rotationAngleRad As Double ' 旋转角度(弧度)% l: q' }. h2 x7 T% w+ X2 c
  16.     Dim intersectPoint As Variant ' 交点' C4 _" g( L! l" n* i
  17.     Dim trimStartPoint As Variant ' 修剪后的起点- |" @4 k- B6 Z3 g- J
  18.     Dim trimEndPoint As Variant ' 修剪后的终点
    ) h5 z( [* d& P/ c7 Y
  19.    
    0 e1 j4 E6 }1 \. B; B6 s5 E
  20.     ' 定义矩形的尺寸
    $ D9 I3 q4 O% a; a  b$ s
  21.     rectWidth = 0.1 ' 矩形的宽度(短边)
    1 v8 T2 C1 ]# T5 S# d
  22.     rectHeight = 1  ' 矩形的高度(长边)
    / o4 g/ ?, r, ?/ n/ }
  23.     $ o- Y/ h$ L; m% x; F; z! j3 Q; g
  24.     ' 提示用户选择一条直线
    8 B: V' r3 T& x! J
  25.     On Error Resume Next, R( \+ e% U8 K; t
  26.     ThisDrawing.Utility.GetEntity lineObj, startPoint, "请选择一条直线: "
    , s5 s' t* r* f( x- ?" i
  27.     On Error GoTo 0
    1 ?7 O; i6 P/ `0 F. D' B& X$ E
  28.     + @: {2 {! {9 w# z
  29.     ' 检查用户是否选择了直线+ p4 {* }1 ^. \- i. c# U. d
  30.     If lineObj Is Nothing Then. T: {) C; N" t# J
  31.         MsgBox "未选择直线或选择无效。"
    4 E. o6 k) b& g/ v6 V1 P! g. O
  32.         Exit Sub/ ~% `( @: K2 D% q8 y1 ~
  33.     End If
    ' g7 j( ~: Z& R  K! ]: n3 @
  34.    
    # H9 M, A1 W% F4 S' @
  35.     ' 获取直线的起点和终点
    6 {6 i7 N$ r. C
  36.     startPoint = lineObj.StartPoint% \% S, I* i! k: G/ M
  37.     endPoint = lineObj.EndPoint' Q) o9 S& @5 Z2 d
  38.     ) t( N$ J$ \) X; U& D9 A7 N
  39.     ' 计算直线的中点4 u) k$ f' a' B6 n7 N; b2 o  L* D
  40.     centerPoint(0) = (startPoint(0) + endPoint(0)) / 2. }9 G  l5 ]  X! q% j5 ]( y3 C! T+ y
  41.     centerPoint(1) = (startPoint(1) + endPoint(1)) / 2
    + g* y& o3 F' S
  42.     centerPoint(2) = (startPoint(2) + endPoint(2)) / 2
    & Q( M9 {8 |- c8 O- h, r# |
  43.     ; k  r! ?0 d0 A
  44.     ' 计算直线的角度(用于矩形的旋转)
    * t; d- c. a1 e7 Z7 n
  45.     rotationAngle = Atn((endPoint(1) - startPoint(1)) / (endPoint(0) - startPoint(0)))6 Z5 f# n6 s( C! k) V
  46.     ( `& t8 D8 j% U/ p; s
  47.     ' 计算矩形的起点和终点8 @6 _; x9 P1 p- n1 Q
  48.     rectStartPoint(0) = startPoint(0) - (rectWidth / 2) * Cos(rotationAngle + (3.14159 / 2))2 v4 n4 Y& d) K' `* Q# n$ H/ f* E
  49.     rectStartPoint(1) = startPoint(1) - (rectWidth / 2) * Sin(rotationAngle + (3.14159 / 2))# m8 g( [# r7 d' R& I/ m% c0 c
  50.     rectStartPoint(2) = startPoint(2)
    8 N, Q/ L: J* r! Y) l; o9 t  t
  51.    
    7 M& a" b' C7 X& n, R0 Z
  52.     rectEndPoint(0) = rectStartPoint(0) + rectHeight * Cos(rotationAngle)/ z/ V, G" Z9 Y/ ]0 k
  53.     rectEndPoint(1) = rectStartPoint(1) + rectHeight * Sin(rotationAngle)
    " P  m% D) J' |$ ~
  54.     rectEndPoint(2) = rectStartPoint(2)
    # p0 T4 q1 a8 c* u8 x
  55.     ( u1 ^7 N, }* G7 ^( n1 x" @/ |; F
  56.     ' 定义矩形的四个顶点: o2 W, H7 j* {8 U9 X8 B
  57.     points(0) = rectStartPoint(0)
    6 B2 E+ r( E, S* \! q) B! B
  58.     points(1) = rectStartPoint(1)
    * f& F- y" w' A) F# {3 a; z! G9 C
  59.     points(2) = rectEndPoint(0)
      `. I, r* b/ T' |
  60.     points(3) = rectEndPoint(1)
    % m- |0 J+ [" O4 p: T
  61.     points(4) = rectEndPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2)). K) t9 h) l# i1 h
  62.     points(5) = rectEndPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))
    6 Z) Y9 ?- U- r% p9 T
  63.     points(6) = rectStartPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))
    ( X( z( P# ^+ c) m4 P4 V
  64.     points(7) = rectStartPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))1 ]4 B1 h4 u& T7 L  Q7 y
  65.    
    . V% c4 h2 Y2 f6 z0 B
  66.     ' 创建矩形: M9 u5 S! L/ }+ _  P, x' d' I7 {
  67.     Set rectObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    ( W" V* O* j# W$ x2 d9 F4 i+ P
  68.    
    : c5 x9 z: Z# y- H) G3 M1 p
  69.     ' 创建圆周阵列(手动复制和旋转)
    % M* l: u/ M+ B0 U- H$ q+ o
  70.     rotationAngleRad = 180 * (3.14159 / 180) ' 将角度转换为弧度
    3 g7 j3 o& F# y6 @7 ]3 g
  71.     Set newRectObj = rectObj.Copy
    2 A% ^- _) m: ]0 G1 g& k
  72.     newRectObj.Rotate centerPoint, rotationAngleRad
    ( H8 f3 q' [% N+ C" y3 S
  73.     8 C$ u; m8 x# L. }4 R8 x9 J$ v) I
  74.     ' 修剪直线
    2 I  o! E. g) f; @! A- c
  75.     ' 查找直线与矩形的交点3 u/ H) S4 K: r  H) h
  76.     intersectPoint = lineObj.IntersectWith(rectObj, acExtendNone)
    & _% @, a9 d- F5 ~- a% A' b( p( d% |" [
  77.     If Not IsEmpty(intersectPoint) Then, B/ o7 @, ]7 C
  78.         ' 修剪直线的起点
    " U8 [4 u7 _4 i8 Y
  79.         trimStartPoint = intersectPoint; {" S: O5 M) u. `3 R. O- m4 s
  80.         lineObj.StartPoint = trimStartPoint
      i( _0 ~# s! E/ o7 `4 c- B
  81.     End If6 f$ L" H3 H' j' G! q
  82.     1 k4 o7 n+ ?% @, c2 p
  83.     intersectPoint = lineObj.IntersectWith(newRectObj, acExtendNone)
    7 P# s* u& e5 G
  84.     If Not IsEmpty(intersectPoint) Then2 S# s; |6 x& J5 X% m
  85.         ' 修剪直线的终点1 n7 F9 [3 i$ V( i  Z' S
  86.         trimEndPoint = intersectPoint
    # H* R( a4 U/ D' }8 k3 q& \
  87.         lineObj.EndPoint = trimEndPoint' F" G% B& ?& I, `* G, Q, y
  88.     End If" ^3 J6 @4 u7 A/ v$ b5 h! Z( X
  89.       W2 t7 c* N7 x
  90.     ' 刷新视图" ^; D; N8 t0 J% \: }
  91.     ThisDrawing.Regen True
    ) j8 r  M* L: ~9 R7 Z
  92.     " {0 u8 ^. p8 M( c& V" r/ \
  93.     ' 提示用户- N' r, Z& R: {* q
  94.     MsgBox "矩形、阵列和修剪操作已完成!"5 Z1 ^" }* l0 F% l6 d
  95. End Sub
复制代码

6 x$ ]0 V8 `! [
) G, w% m. r2 h1 Z/ ^1 c6 J
回复

使用道具 举报

发表于 2025-2-7 10:01:48 | 显示全部楼层
blender也可以。去年试过一次

点评

bl集成了py接口  发表于 2025-2-8 10:31
blender是3D软件,具体说说怎么应用吧。  发表于 2025-2-7 10:10
回复 支持 反对

使用道具 举报

发表于 2025-2-7 10:34:22 | 显示全部楼层
这叫脱裤子放屁,没有任何可行性。
6 V+ {- [3 `2 W& J# V首先怎么保证AI模型的回答不会有幻觉,你保证不了。% u$ [' f7 M( z& a* F3 q5 z
其次怎么保证工程师能识别出AI模型的回答有幻觉,更保证不了,因为多数机械工程师不懂代码。
# M$ {5 Y$ V8 ]最关键的是,AI模型根本不能直接控制CAD,还需要人手工把代码复制粘贴,CAD才会画图。
) d9 K, W. t6 \4 _) L/ T8 H那请问为何不能直接让机械工程师直接画图,你既不能提高效率,又不能节省人工,这么骚操作的意义何在。
回复 支持 反对

使用道具 举报

发表于 2025-2-7 16:04:55 | 显示全部楼层
这个把简单的事情复杂化了
回复 支持 反对

使用道具 举报

发表于 2025-2-8 09:27:49 | 显示全部楼层
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂$ a6 u. m. q. b8 }% M0 e
回复 支持 反对

使用道具 举报

发表于 2025-2-8 09:28:01 | 显示全部楼层
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂; Z" L# b' {6 E  g! R
回复 支持 反对

使用道具 举报

发表于 2025-2-8 09:29:43 | 显示全部楼层
想让他直接出图,标注尺寸,公差,工艺这些,还得大量模型喂他,不过未来的智能化发展,谁能说的准呢
回复 支持 反对

使用道具 举报

发表于 前天 12:19 | 显示全部楼层
我直接给定齿轮参数,让deepseek画齿轮零件图,它明确回答我,他没有此功能,只给出了画图思路,也许以后会实现。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

小黑屋|手机版|Archiver|机械社区 ( 京ICP备10217105号-1,京ICP证050210号,浙公网安备33038202004372号 )

GMT+8, 2025-2-20 07:26 , Processed in 0.063064 second(s), 14 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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