Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Module M_Functions
- Public ActiveDocument1 As Document
- Public Selection1 As Object
- Public reference1 As Reference
- '------------------------------------------------------
- ' ConnectCATIA
- '------------------------------------------------------
- Public Sub ConnectCATIA()
- ' call CATIA
- On Error Resume Next
- If F_Main.CATIA Is Nothing Then
- F_Main.CATIA = GetObject(vbNullString, "CATIA.Application")
- ' CATIA response
- If F_Main.CATIA Is Nothing Then
- Call MsgBox("Could not connect to CATIA", vbCritical + vbOKOnly, "Error")
- End
- End If
- End If
- End Sub
- '------------------------------------------------------
- ' SelectFace
- '------------------------------------------------------
- Sub SelectFace()
- 'Dim ActiveDocument1 As Document
- ActiveDocument1 = F_Main.CATIA.ActiveDocument
- 'Dim Selection1 As Object
- Selection1 = ActiveDocument1.Selection
- Selection1.Clear()
- Dim IOT(0)
- IOT(0) = "PlanarFace"
- Dim strreturn As String
- strreturn = Selection1.SelectElement2(IOT, "Select a planar face", False)
- If strreturn <> "Normal" Then
- Exit Sub
- End If
- 'Dim reference1 As Reference
- reference1 = Selection1.Item(1).Reference
- If TypeName(ActiveDocument1) = "ProductDocument" Then
- F_Main.Part1 = Selection1.Item(1).LeafProduct.ReferenceProduct.Parent.Part
- ElseIf TypeName(ActiveDocument1) = "PartDocument" Then
- F_Main.Part1 = ActiveDocument1.Part
- End If
- End Sub
- '------------------------------------------------------
- ' Create3DText
- '------------------------------------------------------
- Sub Create3DText()
- Dim InWorkObject1 As Object
- InWorkObject1 = F_Main.Part1.InWorkObject
- Dim documents1 As Documents
- documents1 = F_Main.CATIA.Documents
- Dim drawingDocument1 As DrawingDocument
- drawingDocument1 = documents1.Add("Drawing")
- 'drawingDocument1.Standard = catISO
- Dim drawingSheets1 As DrawingSheets
- drawingSheets1 = drawingDocument1.Sheets
- Dim drawingSheet1 As DrawingSheet
- drawingSheet1 = drawingSheets1.Item(1)
- 'drawingSheet1.PaperSize = catPaperA0
- drawingSheet1.[Scale] = 1.0#
- 'drawingSheet1.Orientation = catPaperLandscape
- Dim drawingViews1 As DrawingViews
- drawingViews1 = drawingSheet1.Views
- Dim drawingView1 As DrawingView
- drawingView1 = drawingViews1.Item("Main View")
- Dim drawingTexts1 As DrawingTexts
- drawingTexts1 = drawingView1.Texts
- Dim drawingText1 As DrawingText
- drawingText1 = drawingTexts1.Add(F_Main.TB_Text.Text, 0, 0) '.Item("Text.1")
- If Not F_Main.Font1 Is Nothing Then
- Dim iFontSize As Double
- iFontSize = 100.5
- drawingText1.SetFontSize(0, 0, iFontSize)
- Try
- drawingText1.SetFontName(0, 0, F_Main.Font1.Name & " (TrueType)")
- Catch ex As Exception
- End Try
- End If
- ' TEMP DXF
- Dim TempDXF_Path As String = F_Main.TempDir & "\TEMP.dxf"
- drawingDocument1.ExportData(TempDXF_Path, "dxf")
- drawingDocument1.Close()
- Dim document2 As Document
- document2 = documents1.Open(TempDXF_Path)
- Dim drawingDocument2 As DrawingDocument
- drawingDocument2 = F_Main.CATIA.ActiveDocument
- Dim selection2 As Selection
- selection2 = drawingDocument2.Selection
- selection2.Clear()
- Dim drawingSheets2 As DrawingSheets
- drawingSheets2 = drawingDocument2.Sheets
- Dim drawingSheet2 As DrawingSheet
- 'drawingSheet2 = drawingSheets2.Item("Model")
- drawingSheet2 = drawingSheets2.Item(1)
- Dim drawingViews2 As DrawingViews
- drawingViews2 = drawingSheet2.Views
- Dim drawingView2 As DrawingView
- drawingView2 = drawingViews2.Item("Hauptansicht")
- 'drawingView2 = drawingViews2.Item(1)
- selection2.Add(drawingView2)
- selection2.Copy()
- Selection1.clear()
- Selection1.Add(reference1)
- Selection1.Paste()
- F_Main.Sketch1 = Selection1.item(1).value
- drawingDocument2.Close()
- System.IO.File.Delete(TempDXF_Path)
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement