机械社区
标题:
还有哪些例子可以用DEEPSEEK帮助CAD绘图的?
[打印本页]
作者:
laotoule8
时间:
2025-2-7 09:55
标题:
还有哪些例子可以用DEEPSEEK帮助CAD绘图的?
用了deepseek写的VBA代码用在CAD,挺好用的。有没有其他的方便CAD使用的deepseek的例子推荐一下?
" u) i* N* q R- p9 m
Sub AddRectangleAndArrayAndTrim()
6 F% v4 v7 [( y3 f" Q+ }
' 声明变量
6 I7 c% m+ C! K% [ X8 D
Dim lineObj As Object
e) U2 E+ Q7 E3 r
Dim startPoint As Variant
5 {+ V% @) U5 u+ I+ r( M9 n) M! Y
Dim endPoint As Variant
. i A- B" y6 n$ [* N, E
Dim rectWidth As Double
& t% P6 {9 z0 Z
Dim rectHeight As Double
X3 K2 x: g9 B; h- [5 f
Dim rectStartPoint(0 To 2) As Double
$ z& N& l* D" N) D& j
Dim rectEndPoint(0 To 2) As Double
: {+ K/ g5 U9 i8 B0 {1 Z K8 T
Dim rotationAngle As Double
3 ? I, z% @ N# X, ^5 n1 {
Dim rectObj As Object
5 }1 D3 T& b- K0 V* I
Dim points(0 To 7) As Double ' 用于存储矩形的四个顶点
8 p Y) c, @* L, y4 f
Dim centerPoint(0 To 2) As Double ' 直线的中点
4 j( l9 G: y. d7 ^3 O* f! S
Dim newRectObj As Object ' 复制的矩形对象
0 i2 {" w6 U' S" O& G( m$ b
Dim rotationAngleRad As Double ' 旋转角度(弧度)
, q* {+ |) _) C
Dim intersectPoint As Variant ' 交点
; u# L5 u7 `" t9 `6 O
Dim trimStartPoint As Variant ' 修剪后的起点
5 i! X* x: L+ v y
Dim trimEndPoint As Variant ' 修剪后的终点
. h+ y6 o$ j4 Z! C: m% M6 ~5 r
* f- t. _3 H: V, P; k3 a+ I) C8 Z
' 定义矩形的尺寸
' V1 i6 h. b0 a" r, m# _
rectWidth = 0.1 ' 矩形的宽度(短边)
* Q5 C8 F6 [3 o8 f
rectHeight = 1 ' 矩形的高度(长边)
; B8 G! l/ I' H3 {. v( R3 n8 L$ W! I
( [1 m0 L7 A8 P r
' 提示用户选择一条直线
) U$ E& [6 J0 d+ _0 {& Q x3 w* D1 o
On Error Resume Next
2 H0 ~4 T3 e' L& Z, |$ r, w5 Y
ThisDrawing.Utility.GetEntity lineObj, startPoint, "请选择一条直线: "
( A0 \1 F+ n3 J. w6 `4 Q6 V/ R
On Error GoTo 0
- S! {( I: p' ?4 s1 f3 Z+ z
1 G5 |& j" z3 z' {2 Q, a" ?
' 检查用户是否选择了直线
8 M7 l) B6 ?( }5 Z9 A9 V
If lineObj Is Nothing Then
0 w& G6 ]$ e" W) }& O1 T
MsgBox "未选择直线或选择无效。"
& O2 a2 k3 N& p4 R4 i
Exit Sub
T2 T% G) u# Q- p
End If
# ?) J3 ?2 j: ^2 _* ?3 u
2 |8 B8 x1 |. }" O
' 获取直线的起点和终点
2 U1 `& O4 o. W" L
startPoint = lineObj.StartPoint
4 j2 _: j1 w# h" l
endPoint = lineObj.EndPoint
$ i$ \$ K( u+ O2 a
, `; w8 {0 c+ G; m, j
' 计算直线的中点
4 ^8 f0 Z" d( p; K+ o) S/ F
centerPoint(0) = (startPoint(0) + endPoint(0)) / 2
5 l) h7 o |* }% v) k
centerPoint(1) = (startPoint(1) + endPoint(1)) / 2
2 _% e+ T! N. R" {
centerPoint(2) = (startPoint(2) + endPoint(2)) / 2
4 A! \) `- v. S: V3 r
$ A0 P& w) \) V1 `% h: O
' 计算直线的角度(用于矩形的旋转)
) I! @8 M7 b5 w
rotationAngle = Atn((endPoint(1) - startPoint(1)) / (endPoint(0) - startPoint(0)))
& N9 b: G( a2 L. y- u9 ~9 U6 v& }% q, |
' W0 _$ c) D: z/ L' \) x4 {% T) E! {
' 计算矩形的起点和终点
' D9 P$ Q" L6 |6 w+ N3 m7 D
rectStartPoint(0) = startPoint(0) - (rectWidth / 2) * Cos(rotationAngle + (3.14159 / 2))
5 t3 V! z% F0 k* F+ C# ]
rectStartPoint(1) = startPoint(1) - (rectWidth / 2) * Sin(rotationAngle + (3.14159 / 2))
1 A6 g/ ~7 n/ \1 d! v% V
rectStartPoint(2) = startPoint(2)
& @& w, R8 ^) i+ E3 u0 X$ m- X
9 [9 U. A) W }. G
rectEndPoint(0) = rectStartPoint(0) + rectHeight * Cos(rotationAngle)
{ L; U. I; W/ o
rectEndPoint(1) = rectStartPoint(1) + rectHeight * Sin(rotationAngle)
/ K7 I8 _ c* f$ e g, w& X
rectEndPoint(2) = rectStartPoint(2)
0 o! p1 p7 X6 v
, S ]! x0 }$ c0 G! }9 L
' 定义矩形的四个顶点
" g- q0 V0 {7 c
points(0) = rectStartPoint(0)
* S7 ~/ a R0 G- W0 [" w
points(1) = rectStartPoint(1)
0 @. q7 L/ Y8 Y
points(2) = rectEndPoint(0)
; T! M9 n8 [" n/ G
points(3) = rectEndPoint(1)
% L$ ?2 o0 g9 k+ n6 s0 j0 t
points(4) = rectEndPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))
$ `5 F* A y* z! W% C c
points(5) = rectEndPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))
6 K) B. d3 C* q7 N; X! d# T2 M! g
points(6) = rectStartPoint(0) + rectWidth * Cos(rotationAngle + (3.14159 / 2))
0 m: t( x- w8 q0 Z+ H$ |: J( F
points(7) = rectStartPoint(1) + rectWidth * Sin(rotationAngle + (3.14159 / 2))
! L( |8 h9 Q' G& d5 H3 A6 I J
8 p2 `0 D9 z1 k B" e% u5 s
' 创建矩形
6 ~) k8 R; {/ |, I! B
Set rectObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
$ W+ i% i% C, U/ T! q
; ~# k$ R C: W" T9 P/ |
' 创建圆周阵列(手动复制和旋转)
1 ?' V) f5 k$ R5 _# ^ L# i
rotationAngleRad = 180 * (3.14159 / 180) ' 将角度转换为弧度
& B' A, `1 g! d( |2 d' s
Set newRectObj = rectObj.Copy
@1 J* q$ E. M9 o2 U9 p
newRectObj.Rotate centerPoint, rotationAngleRad
1 ?, c4 U3 C y4 n" X5 F) l
2 q. M$ q1 T/ X# @
' 修剪直线
6 n2 ?$ v4 `0 O
' 查找直线与矩形的交点
/ b# }/ Q( G" s: p$ t
intersectPoint = lineObj.IntersectWith(rectObj, acExtendNone)
. @3 e ^1 Y1 X0 L7 s! r1 c j/ Z
If Not IsEmpty(intersectPoint) Then
% H+ f2 s, T l9 x4 @6 F m2 u" Y
' 修剪直线的起点
$ p+ }" y% ]& K2 ]
trimStartPoint = intersectPoint
( s* I0 z) Q& G
lineObj.StartPoint = trimStartPoint
; z3 ~! C6 ]% y( Z% U
End If
# a9 D8 W7 G7 S
) x# _9 U: t. j8 {
intersectPoint = lineObj.IntersectWith(newRectObj, acExtendNone)
2 [: T. [; _8 v7 E7 V2 s! O5 A$ ~
If Not IsEmpty(intersectPoint) Then
3 a! I3 W6 H! N0 H
' 修剪直线的终点
' |3 A0 B0 o! V9 n9 ^% J$ F( k/ @. L
trimEndPoint = intersectPoint
i4 W$ l" k' O, [; |8 @0 W6 y
lineObj.EndPoint = trimEndPoint
% v5 y! O9 L8 }9 {" ~
End If
1 ~! G$ l w) c4 g4 }7 w. q
: ?& j( l0 Y& s2 {( z
' 刷新视图
1 j0 e5 }& r/ j3 j/ E$ C+ \1 ?
ThisDrawing.Regen True
% W5 Y. V0 F, A$ c0 p- C$ Q
) Q2 S( _, ~$ ` ]8 Q
' 提示用户
3 ?4 d5 s# M! {
MsgBox "矩形、阵列和修剪操作已完成!"
. B. X9 ~# i5 _5 x% J# O( W7 e1 U7 `
End Sub
复制代码
m3 o+ m# z+ Q. ]
1 B" R; R- b; G/ c9 [1 H# M
作者:
564156415gdr
时间:
2025-2-7 10:01
blender也可以。去年试过一次
作者:
学者11
时间:
2025-2-7 10:34
这叫脱裤子放屁,没有任何可行性。
8 c2 a0 \" z0 Z8 R) G$ E
首先怎么保证AI模型的回答不会有幻觉,你保证不了。
k, d6 ?* z# S; i2 N" \! D w
其次怎么保证工程师能识别出AI模型的回答有幻觉,更保证不了,因为多数机械工程师不懂代码。
" E0 u- h- i5 E. F
最关键的是,AI模型根本不能直接控制CAD,还需要人手工把代码复制粘贴,CAD才会画图。
: m9 b7 z2 a& q. k* _
那请问为何不能直接让机械工程师直接画图,你既不能提高效率,又不能节省人工,这么骚操作的意义何在。
作者:
kayex
时间:
2025-2-7 16:04
这个把简单的事情复杂化了
作者:
寰宇无人
时间:
2025-2-8 09:27
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂
; W. t9 |( d/ Q8 d
作者:
寰宇无人
时间:
2025-2-8 09:28
以前用在SW二次开发上也行,主体代码能用,但一些自定义需求,以及配置啥的,自己要懂
, H+ ?9 l3 X5 g7 t) W: x# e
作者:
寰宇无人
时间:
2025-2-8 09:29
想让他直接出图,标注尺寸,公差,工艺这些,还得大量模型喂他,不过未来的智能化发展,谁能说的准呢
作者:
zhl6200
时间:
2025-2-18 12:19
我直接给定齿轮参数,让deepseek画齿轮零件图,它明确回答我,他没有此功能,只给出了画图思路,也许以后会实现。
欢迎光临 机械社区 (http://www.cmiw.cn/)
Powered by Discuz! X3.5