找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 8354|回复: 9

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

[复制链接]
发表于 2025-2-7 09:55:16 | 显示全部楼层 |阅读模式
用了deepseek写的VBA代码用在CAD,挺好用的。有没有其他的方便CAD使用的deepseek的例子推荐一下?: c  v$ Q6 M8 ^# V6 s9 W$ L7 X
  1. Sub AddRectangleAndArrayAndTrim()
    ) w- ]" f* K* A* {% M7 G
  2.     ' 声明变量
    4 J( E2 a4 R4 q+ d+ C1 v1 [
  3.     Dim lineObj As Object
    , d) y% V- T4 D- B4 a  q: t
  4.     Dim startPoint As Variant
    : \+ i! O% ^5 U0 ^; |: P+ z
  5.     Dim endPoint As Variant
    & P( @# E. J: H) Y/ D4 B: C; M4 i: D
  6.     Dim rectWidth As Double
    # e% V8 z3 X: @' v5 ]: l- @
  7.     Dim rectHeight As Double% L  ^0 T  r. F8 a
  8.     Dim rectStartPoint(0 To 2) As Double
    ) K* U0 M! n0 z1 [( N( U2 |
  9.     Dim rectEndPoint(0 To 2) As Double
    3 u; S' e1 G# w- a* y
  10.     Dim rotationAngle As Double6 j$ z8 d- d3 M, V! v- B- c
  11.     Dim rectObj As Object  n: e: n0 O5 }1 F
  12.     Dim points(0 To 7) As Double ' 用于存储矩形的四个顶点4 N2 `& p/ ^1 c6 y2 F! D: d4 p( r
  13.     Dim centerPoint(0 To 2) As Double ' 直线的中点8 r& v  m( @5 E5 l0 q$ W! k
  14.     Dim newRectObj As Object ' 复制的矩形对象: T$ `6 X) Z8 j( D: n# _- g$ T
  15.     Dim rotationAngleRad As Double ' 旋转角度(弧度)/ B! @$ W! {3 \& k, f& Y/ h2 T* a
  16.     Dim intersectPoint As Variant ' 交点
    * h* P2 A/ u& Y, e
  17.     Dim trimStartPoint As Variant ' 修剪后的起点4 f, j+ S# A8 ]
  18.     Dim trimEndPoint As Variant ' 修剪后的终点
    ' h# N2 F# d9 S$ _2 h; c1 o* l/ V
  19.    
    ; |- m) j( f4 h& `
  20.     ' 定义矩形的尺寸; X$ ?' Y1 j+ x* }7 n# y2 @% _
  21.     rectWidth = 0.1 ' 矩形的宽度(短边), Y, [8 d. [& d% c
  22.     rectHeight = 1  ' 矩形的高度(长边). H$ o/ H+ N, N% o
  23.    
    : c5 x$ c& l7 \9 D$ k
  24.     ' 提示用户选择一条直线
    / ~6 X/ L9 W. ?2 D: d' A" [; f) Q
  25.     On Error Resume Next+ ]4 t/ o  h% F; N( J
  26.     ThisDrawing.Utility.GetEntity lineObj, startPoint, "请选择一条直线: "
    - W3 C2 y( J% G2 W. ^7 R5 l
  27.     On Error GoTo 01 S& f  T/ Y7 l  G7 U3 h
  28.    
    3 w3 o; V7 n# i1 m
  29.     ' 检查用户是否选择了直线
    ' }6 s6 c  E# j1 u
  30.     If lineObj Is Nothing Then
    5 Y8 \+ C. z2 B( s1 g4 h
  31.         MsgBox "未选择直线或选择无效。"' \! }! [4 F- C. L" v( O( x
  32.         Exit Sub
    . ~1 W& I0 P& E1 G- `) F" E
  33.     End If2 s9 M- ?) {- `- v+ h. l
  34.    
    / Z6 C; Q' G! `! |1 U+ \
  35.     ' 获取直线的起点和终点" b7 H+ ~/ p; z  z
  36.     startPoint = lineObj.StartPoint
    8 k$ e; [6 _2 r+ }( d( Z$ K3 C! @! i
  37.     endPoint = lineObj.EndPoint9 _) L* R5 R# Q0 o& y% R7 S
  38.    
    % M: O1 m4 Q- S' w3 V
  39.     ' 计算直线的中点
    4 }7 Y  U) |2 Y4 y% Y$ Y( ^* A
  40.     centerPoint(0) = (startPoint(0) + endPoint(0)) / 2
    - [6 ]/ @. `. v3 s* c$ H
  41.     centerPoint(1) = (startPoint(1) + endPoint(1)) / 2
    . v: M, e* a5 f0 U
  42.     centerPoint(2) = (startPoint(2) + endPoint(2)) / 2
    # I! C, ^! ]2 c
  43.     2 ~& k* X% q1 x" ?
  44.     ' 计算直线的角度(用于矩形的旋转)
    6 \7 P- ?( F9 a
  45.     rotationAngle = Atn((endPoint(1) - startPoint(1)) / (endPoint(0) - startPoint(0)))
    # o& d2 r  m. V( }8 ^/ b6 D) i
  46.     9 Q; W" A" k$ I: i
  47.     ' 计算矩形的起点和终点
    ! T9 x6 I2 H, p
  48.     rectStartPoint(0) = startPoint(0) - (rectWidth / 2) * Cos(rotationAngle + (3.14159 / 2))+ b; q- D" p) O8 j/ p
  49.     rectStartPoint(1) = startPoint(1) - (rectWidth / 2) * Sin(rotationAngle + (3.14159 / 2))
    + L2 S- Q4 f( a2 X( _: ~9 R
  50.     rectStartPoint(2) = startPoint(2)
    8 N6 z7 l7 a: ^2 B3 j
  51.     # R$ W! J# P8 ]: Z0 S6 E/ ]) K
  52.     rectEndPoint(0) = rectStartPoint(0) + rectHeight * Cos(rotationAngle)7 e6 K5 A  x: g- y! ^
  53.     rectEndPoint(1) = rectStartPoint(1) + rectHeight * Sin(rotationAngle)1 l2 g$ P* h" L
  54.     rectEndPoint(2) = rectStartPoint(2)
    . H; T5 H8 ~$ l6 n9 `, c
  55.    
    8 k, S$ _7 k3 a
  56.     ' 定义矩形的四个顶点
    7 O* B  v" @1 m: z
  57.     points(0) = rectStartPoint(0)  m- P) y4 P2 F
  58.     points(1) = rectStartPoint(1)/ P/ R; O) R8 B; W( G
  59.     points(2) = rectEndPoint(0)
    5 ]" d  `2 t$ |% Z' S; |
  60.     points(3) = rectEndPoint(1)2 \: S: O* E; F3 L
  61.     points(4) = rectEndPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))
    7 K( Y+ `. \1 k0 p
  62.     points(5) = rectEndPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))3 I" k  V" \7 D9 D2 c! I
  63.     points(6) = rectStartPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))
    ) k; T1 J/ Q% O4 P
  64.     points(7) = rectStartPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))1 T& L; b+ p2 R+ W5 P- C
  65.    
    5 \) `& t9 K# a4 M7 m
  66.     ' 创建矩形
    ! @1 T# u) V  @5 J$ `! m
  67.     Set rectObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)* U0 o) b1 L2 G
  68.     " P+ C/ v' K- X( r, q0 l7 s
  69.     ' 创建圆周阵列(手动复制和旋转)
    9 @& e7 ^$ q, w
  70.     rotationAngleRad = 180 * (3.14159 / 180) ' 将角度转换为弧度' t0 `7 M: F) B& I8 |( n$ C
  71.     Set newRectObj = rectObj.Copy
    1 }& {3 V- U( ^- w4 E
  72.     newRectObj.Rotate centerPoint, rotationAngleRad7 g+ i) |2 {2 l* K
  73.     3 c7 U  l* |& U: ?* o* t2 m
  74.     ' 修剪直线+ K2 g: _6 n2 i% j( T9 i* S
  75.     ' 查找直线与矩形的交点4 u: Y+ F# C1 w$ h+ o
  76.     intersectPoint = lineObj.IntersectWith(rectObj, acExtendNone)
    4 k4 g0 P) X5 k: d- C' O& e
  77.     If Not IsEmpty(intersectPoint) Then+ i9 H3 _$ \' k% k! U
  78.         ' 修剪直线的起点
    3 M  }& s9 m# O) r
  79.         trimStartPoint = intersectPoint
    8 b5 ^* F. o1 \- A/ g% W# o
  80.         lineObj.StartPoint = trimStartPoint
    . J1 N+ `8 {/ L& S* E2 z
  81.     End If' f$ q' F- |! T# i+ Z
  82.    
    ( U3 v2 c' G- |- Z- K( V
  83.     intersectPoint = lineObj.IntersectWith(newRectObj, acExtendNone)5 D. x  N* z( G) E6 W( f
  84.     If Not IsEmpty(intersectPoint) Then  \7 m! q+ }. w* D& {9 t# v
  85.         ' 修剪直线的终点
    3 E! `: N6 X! k
  86.         trimEndPoint = intersectPoint
    % w% a' e1 r3 a. Y
  87.         lineObj.EndPoint = trimEndPoint
    ( s( f9 c  r  _
  88.     End If
    * z8 o( s0 {/ x/ t" ?5 Q4 _9 `3 Q
  89.    
    6 L& K6 o: K% H9 S
  90.     ' 刷新视图
    & J$ l/ O% ?3 t/ B( S5 M) {, u
  91.     ThisDrawing.Regen True7 v9 |  r' D% F8 f' l9 ?; ?, J  b
  92.    
    8 t) }/ l/ E* o( V& [
  93.     ' 提示用户
    ; {5 ^1 J( w- Z5 K8 O3 }- Z% _
  94.     MsgBox "矩形、阵列和修剪操作已完成!"
    . L9 R9 r" }) S; P: Q* L
  95. End Sub
复制代码
! n$ P# U2 s7 N* K
# d9 D# m6 B* o5 b
回复

使用道具 举报

发表于 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 | 显示全部楼层
这叫脱裤子放屁,没有任何可行性。1 F; f0 s; y$ D5 X9 f# m
首先怎么保证AI模型的回答不会有幻觉,你保证不了。2 F" {# U* _. S  w2 Q0 d6 I
其次怎么保证工程师能识别出AI模型的回答有幻觉,更保证不了,因为多数机械工程师不懂代码。1 d# y5 M/ i& {3 `
最关键的是,AI模型根本不能直接控制CAD,还需要人手工把代码复制粘贴,CAD才会画图。. g6 B. [, |6 w
那请问为何不能直接让机械工程师直接画图,你既不能提高效率,又不能节省人工,这么骚操作的意义何在。
发表于 2025-2-7 16:04:55 | 显示全部楼层
这个把简单的事情复杂化了
发表于 2025-2-8 09:27:49 | 显示全部楼层
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂' [, N1 x* K. v4 d( x  A3 m& V
发表于 2025-2-8 09:28:01 | 显示全部楼层
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂
6 ?" y7 W- k  a5 F0 G0 Z
发表于 2025-2-8 09:29:43 | 显示全部楼层
想让他直接出图,标注尺寸,公差,工艺这些,还得大量模型喂他,不过未来的智能化发展,谁能说的准呢
发表于 2025-2-18 12:19:00 | 显示全部楼层
我直接给定齿轮参数,让deepseek画齿轮零件图,它明确回答我,他没有此功能,只给出了画图思路,也许以后会实现。
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

GMT+8, 2025-9-16 03:12 , Processed in 0.058327 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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