티스토리 뷰

반응형

Solid Edge 좌표계 자동 작성 매크로 입니다.

Excel 이용해 좌표계 생성 하는 매크로입니다.


코드 소스

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Option Explicit
 
'Excel -> Edge
Sub Make_Coordnate()
On Error Resume Next
 
Dim EDGE As SolidEdgeFramework.Application
Dim EDoc As SolidEdgePart.PartDocument
Dim OldStBar As String
 
Set EDGE = GetObject(, "SolidEdge.Application")
If EDGE Is Nothing Then
    Err.Clear
    Set EDGE = CreateObject("SolidEdge.Application")
    Set EDoc = EDGE.Documents.Add("SolidEdge.PartDocument")
    EDGE.Visible = True
    EDGE.DisplayFullScreen = True
Else
      Set EDoc = EDGE.Documents.Add("SolidEdge.PartDocument")
End If
 
EDoc.Application.ScreenUpdating = False
OldStBar = EDGE.StatusBar
 
Dim AXIS As Object
Dim i As Integer
Dim K As Integer
Dim X As Double
Dim Y As Double
Dim Z As Double
Dim No As String
 
On Error GoTo ET
 
K = Cells(Rows.Count, "a").End(xlUp).Row
 
For i = 4 To K Step 3
If Cells(i + 2, 3) <> 0 And Cells(i + 1, 3) <> 0 And Cells(i, 3) <> 0 Then
    X = Cells(i, 3) / 1000
    Y = Cells(i + 1, 3) / 1000
    Z = Cells(i + 2, 3) / 1000
    No = Cells(i, 1)
    EDGE.StatusBar = "  Task Progress   " & Round(i / K * 100, 0) & "%"
    Set AXIS = EDoc.CoordinateSystems.Add(X, Y, Z)
    AXIS.Name = No
End If
 
Next
 
EDGE.StatusBar = OldStBar
EDoc.Application.ScreenUpdating = True
Call EDoc.Recompute
 
Exit Sub
 
ET:
EDoc.Application.ScreenUpdating = True
Call EDoc.Recompute
MsgBox "Error...", "wkdghfl@gmail.com"
 
End Sub


Excel 파일


소스를 직접 편집해 사용하시거나 아래의 Excel 파일을 이용하시면 됩니다.

좌측은 좌표계 이름, 우측이 축 거리값 입니다.

두 부분을 입력후 실행하면 좌표계가 생성됩니다.


Creates Coordinate.xlsm



반응형

'프로그래밍 > SolidEdge' 카테고리의 다른 글

SolidEdge C# 템플릿  (0) 2018.04.20
SolidEdge API 오류  (0) 2018.03.20
Edge VBA 시작  (0) 2018.02.07
Solid Edge 매크로  (0) 2018.02.06