找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 8361|回复: 9

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

[复制链接]
发表于 2025-2-7 09:55:16 | 显示全部楼层 |阅读模式
用了deepseek写的VBA代码用在CAD,挺好用的。有没有其他的方便CAD使用的deepseek的例子推荐一下?
! o) }" O" D$ W  m, X
  1. Sub AddRectangleAndArrayAndTrim()
    ) W1 C; N+ P4 q. [
  2.     ' 声明变量
    1 g0 c* O  W  b
  3.     Dim lineObj As Object5 p; V/ N+ A$ F, c) x( S
  4.     Dim startPoint As Variant
    * O; T& Y. t% }2 |' g8 ^* u  G
  5.     Dim endPoint As Variant+ E1 ^5 i' e! i. H. W6 G
  6.     Dim rectWidth As Double
    % y) d/ J3 _& O. N9 S& [3 M
  7.     Dim rectHeight As Double) |$ K$ [$ d/ N1 V0 C
  8.     Dim rectStartPoint(0 To 2) As Double. ]8 X7 d0 u# e
  9.     Dim rectEndPoint(0 To 2) As Double
    $ o8 m+ `' L2 Q. B0 n
  10.     Dim rotationAngle As Double
      |1 T& r# ^4 _3 D' ]: h. Q% H+ j8 I% \* T
  11.     Dim rectObj As Object
    3 d$ v' m/ A/ ]; c/ P8 |: U- L
  12.     Dim points(0 To 7) As Double ' 用于存储矩形的四个顶点
    : A& E8 q) c6 }* I4 ]3 r
  13.     Dim centerPoint(0 To 2) As Double ' 直线的中点  `$ y& @8 ^+ \9 K8 a4 h# w
  14.     Dim newRectObj As Object ' 复制的矩形对象3 p" F# f4 H* F- I7 ^& [
  15.     Dim rotationAngleRad As Double ' 旋转角度(弧度)
    0 f) z# p; V; V. j" H+ E6 M; z, W
  16.     Dim intersectPoint As Variant ' 交点/ P6 z0 N/ F5 H5 e7 U
  17.     Dim trimStartPoint As Variant ' 修剪后的起点
    # p" f8 f% {- V8 D, e: y* X7 P0 a
  18.     Dim trimEndPoint As Variant ' 修剪后的终点4 y; y) }+ g( t# H/ k
  19.     / w% X: S( ?# P, t
  20.     ' 定义矩形的尺寸
    - q) P6 N8 ]( w( ?
  21.     rectWidth = 0.1 ' 矩形的宽度(短边)4 |: w3 m+ s3 L6 h
  22.     rectHeight = 1  ' 矩形的高度(长边)
    ) J3 s7 @4 Q1 T* @" k  z
  23.    
    " Z. P+ w4 o' l' R8 @
  24.     ' 提示用户选择一条直线
    9 T- x6 c% P* J5 ~! k2 a) W, Q
  25.     On Error Resume Next
    ' R7 p% k8 r4 ^3 C. e" i1 q, G
  26.     ThisDrawing.Utility.GetEntity lineObj, startPoint, "请选择一条直线: "$ {# @$ g9 @4 j% ^0 q, t/ X
  27.     On Error GoTo 0
    : o& g" t3 c; w1 O. o0 J  U' o& h$ F
  28.     , J- J) k- U1 R& i  c0 ^" P
  29.     ' 检查用户是否选择了直线
    6 v) N$ L/ H8 j
  30.     If lineObj Is Nothing Then
    ( J! ?; c: ~  ]& [
  31.         MsgBox "未选择直线或选择无效。"
    ) u' ^) _2 i: o  l! V
  32.         Exit Sub
    ( w5 ?% x) x* F# h
  33.     End If
    . y7 Y, n0 g3 D
  34.    
    * _& [) o9 ^9 B6 I( O
  35.     ' 获取直线的起点和终点" {. ]2 o7 N. b" j% p
  36.     startPoint = lineObj.StartPoint
    - t- o- j1 l% j8 `% s  l, b8 p
  37.     endPoint = lineObj.EndPoint
    , A! f1 D. B6 M$ v, b, |. Z$ t/ j
  38.     ' ?" k) Q, n$ c& d
  39.     ' 计算直线的中点
    7 Q, m2 `4 Q- ^, U4 [0 V
  40.     centerPoint(0) = (startPoint(0) + endPoint(0)) / 2
    & ^* R2 }1 {* S* T& J5 e
  41.     centerPoint(1) = (startPoint(1) + endPoint(1)) / 2- T) n$ L. n( j: e9 w9 T
  42.     centerPoint(2) = (startPoint(2) + endPoint(2)) / 2
    6 S7 i: F2 s" z+ N2 t
  43.    
    6 I& D$ d! O3 L' ?( x( i$ d* ^
  44.     ' 计算直线的角度(用于矩形的旋转)% J* o5 i& c; H4 {* O
  45.     rotationAngle = Atn((endPoint(1) - startPoint(1)) / (endPoint(0) - startPoint(0)))
    ) \' V3 S! }$ p2 i1 S+ b/ y. O
  46.     ) T3 ]* o) N' S. l  D" ~9 R1 B# ?3 ?  q
  47.     ' 计算矩形的起点和终点
    6 X  m, t7 t- {8 g
  48.     rectStartPoint(0) = startPoint(0) - (rectWidth / 2) * Cos(rotationAngle + (3.14159 / 2))" \1 i0 `2 z8 {7 M+ z: L
  49.     rectStartPoint(1) = startPoint(1) - (rectWidth / 2) * Sin(rotationAngle + (3.14159 / 2))( I, x% \  u/ V% n$ L$ M
  50.     rectStartPoint(2) = startPoint(2). r5 D& M* a+ P# k  u
  51.     7 ^2 Z2 t5 u) J* A# L- t! m; O7 M
  52.     rectEndPoint(0) = rectStartPoint(0) + rectHeight * Cos(rotationAngle)
    & v9 L& @. G3 {
  53.     rectEndPoint(1) = rectStartPoint(1) + rectHeight * Sin(rotationAngle)
    . ~6 x$ s+ H7 N- _9 V* f, h
  54.     rectEndPoint(2) = rectStartPoint(2)
    $ F8 q  r) r; D0 x: e" _2 U9 K, O9 V
  55.     / n' q0 @0 {. ~8 w+ }* Z4 L+ x8 x
  56.     ' 定义矩形的四个顶点7 B2 [) c- J6 K, y  \7 m
  57.     points(0) = rectStartPoint(0)
    * D, j4 G5 g* D* J
  58.     points(1) = rectStartPoint(1)6 ~* @- B6 |$ C& ^! E) R% A- b; V
  59.     points(2) = rectEndPoint(0)
    - W$ R- g1 D& ]7 E. v
  60.     points(3) = rectEndPoint(1)5 K3 t8 B& y1 F& D
  61.     points(4) = rectEndPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))) I& f; J9 a) a. K: X4 b
  62.     points(5) = rectEndPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))
    " g8 M6 m9 ?# R( y' H' D
  63.     points(6) = rectStartPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))* n. i9 f% y. a6 R, r
  64.     points(7) = rectStartPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))
    # W8 r% [; f3 X. f" P  O, I
  65.     % N) a, j1 J5 V8 o# }" |& C
  66.     ' 创建矩形- x% E6 _( I  z& n$ K7 G+ X
  67.     Set rectObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)6 H1 `+ P6 F3 Z8 _3 |$ q
  68.    
    ( h: g8 t% g1 v8 c& _1 M! z  J
  69.     ' 创建圆周阵列(手动复制和旋转)
    : T' M1 Y, i) j
  70.     rotationAngleRad = 180 * (3.14159 / 180) ' 将角度转换为弧度9 V% f. U  O6 E  s% A! f
  71.     Set newRectObj = rectObj.Copy( X% r% S* v7 @& I1 Z5 f
  72.     newRectObj.Rotate centerPoint, rotationAngleRad6 J  T% \4 p4 K
  73.    
    - C" S2 C# ?2 O- W0 C4 j' g6 Q! j
  74.     ' 修剪直线
    & _+ j' i, S6 e! {! e. T- F
  75.     ' 查找直线与矩形的交点
    ; ~. z! s4 I/ T
  76.     intersectPoint = lineObj.IntersectWith(rectObj, acExtendNone)+ X. C5 T4 [9 Z
  77.     If Not IsEmpty(intersectPoint) Then
    * Q, Q, d7 z: \
  78.         ' 修剪直线的起点
    7 y1 C8 d6 R' N" F+ @! q( r
  79.         trimStartPoint = intersectPoint
    1 P# }& s4 j# b& ]
  80.         lineObj.StartPoint = trimStartPoint
    $ h9 ^) N2 ^, }
  81.     End If* [% C' U0 v! n3 w2 c% A
  82.    
    2 o; j6 M! Z+ {4 {
  83.     intersectPoint = lineObj.IntersectWith(newRectObj, acExtendNone)  L; P5 m1 \7 Z: ^  ]5 Z1 @
  84.     If Not IsEmpty(intersectPoint) Then8 c. X* L9 `& r% @( N. X9 F
  85.         ' 修剪直线的终点6 R( q+ n  q# P* p3 ^, K  y: y: O
  86.         trimEndPoint = intersectPoint; Q" J  r3 y$ U+ N% T7 S- @
  87.         lineObj.EndPoint = trimEndPoint
    , u# A# \( E7 S; P# ^( o
  88.     End If, p3 G9 w! {* e
  89.     4 v3 [' q- p3 _
  90.     ' 刷新视图
    - J3 x( d0 W# j
  91.     ThisDrawing.Regen True
    + h* }/ H2 I& l
  92.     ) P( _0 T* h2 d
  93.     ' 提示用户
    2 G! e4 ~4 z- Y
  94.     MsgBox "矩形、阵列和修剪操作已完成!"$ a1 u$ {. y" ?0 Y/ p
  95. End Sub
复制代码
2 D/ b3 K7 }9 K: p2 e% b2 c9 s
+ \: X6 x2 z6 o! m  d1 G6 E# W
回复

使用道具 举报

发表于 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 | 显示全部楼层
这叫脱裤子放屁,没有任何可行性。  @. j; H) n7 s
首先怎么保证AI模型的回答不会有幻觉,你保证不了。/ u- Q4 x5 h: F" O# g
其次怎么保证工程师能识别出AI模型的回答有幻觉,更保证不了,因为多数机械工程师不懂代码。
- P. W3 G2 |+ b* w, f2 y8 Q最关键的是,AI模型根本不能直接控制CAD,还需要人手工把代码复制粘贴,CAD才会画图。
3 Y3 b  B. [! O7 W  [2 S# m) I# k那请问为何不能直接让机械工程师直接画图,你既不能提高效率,又不能节省人工,这么骚操作的意义何在。
发表于 2025-2-7 16:04:55 | 显示全部楼层
这个把简单的事情复杂化了
发表于 2025-2-8 09:27:49 | 显示全部楼层
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂+ z' H/ \" u' a3 j
发表于 2025-2-8 09:28:01 | 显示全部楼层
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂2 ]! O. X, _) Y5 ~/ q4 H% R- w
发表于 2025-2-8 09:29:43 | 显示全部楼层
想让他直接出图,标注尺寸,公差,工艺这些,还得大量模型喂他,不过未来的智能化发展,谁能说的准呢
发表于 2025-2-18 12:19:00 | 显示全部楼层
我直接给定齿轮参数,让deepseek画齿轮零件图,它明确回答我,他没有此功能,只给出了画图思路,也许以后会实现。
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

GMT+8, 2025-9-17 15:59 , Processed in 0.056934 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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