Alan Lowbands
Aerospace
Hi,
Could anyone help me with this problem.
I'm trying to run a macro that will select a body in a part and drop it onto a drawing sheet.
I've got it to work to a small degree with bits of code cobbled together but I can't find a way to let me select the face I want for my view.
any help as always would be really appreciated.
code I have is below
regards
Alan
---------------------------------------------------------------------
Language="VBSCRIPT"
Sub CATMain()
Dim partDocument1 'As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 'As Part
Set part1 = partDocument1.Part
Dim oSel 'as Selection
Set oSel = partDocument1.selection
Dim Filter(0)
Filter(0)="Body"
Dim F_Body 'as object
F_Body=oSel.selectelement2(Filter, " Select Body in which you want to add", False)
Dim bodies1 'As Bodies
Set bodies1 = part1.Bodies
Dim body1 'As Body
Set body1 = bodies1.Item(oSel.item(1).value.name)
Set documents1 = CATIA.Documents
Set drawingDocument1 = documents1.Add("Drawing")
drawingDocument1.Standard = catISO
Set drawingSheets1 = drawingDocument1.Sheets
Set drawingSheet1 = drawingSheets1.Item("Sheet.1")
drawingSheet1.PaperSize = catPaperA0
drawingSheet1.Scale = 1.000000
drawingSheet1.Orientation = catPaperLandscape
Set drawingViews1 = drawingSheet1.Views
Set drawingView1 = drawingViews1.Add("AutomaticNaming")
Set drawingViewGenerativeLinks1 = drawingView1.GenerativeLinks
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
drawingViewGenerativeLinks1.AddLink body1
drawingViewGenerativeBehavior1.DefineFrontView 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000
drawingView1.x = 594.500000
drawingView1.y = 420.500000
drawingView1.Scale = 1.000000
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
drawingViewGenerativeBehavior1.Update
drawingView1.Activate
End Sub
---------------------------------------------------------------------------------------------------
Could anyone help me with this problem.
I'm trying to run a macro that will select a body in a part and drop it onto a drawing sheet.
I've got it to work to a small degree with bits of code cobbled together but I can't find a way to let me select the face I want for my view.
any help as always would be really appreciated.
code I have is below
regards
Alan
---------------------------------------------------------------------
Language="VBSCRIPT"
Sub CATMain()
Dim partDocument1 'As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 'As Part
Set part1 = partDocument1.Part
Dim oSel 'as Selection
Set oSel = partDocument1.selection
Dim Filter(0)
Filter(0)="Body"
Dim F_Body 'as object
F_Body=oSel.selectelement2(Filter, " Select Body in which you want to add", False)
Dim bodies1 'As Bodies
Set bodies1 = part1.Bodies
Dim body1 'As Body
Set body1 = bodies1.Item(oSel.item(1).value.name)
Set documents1 = CATIA.Documents
Set drawingDocument1 = documents1.Add("Drawing")
drawingDocument1.Standard = catISO
Set drawingSheets1 = drawingDocument1.Sheets
Set drawingSheet1 = drawingSheets1.Item("Sheet.1")
drawingSheet1.PaperSize = catPaperA0
drawingSheet1.Scale = 1.000000
drawingSheet1.Orientation = catPaperLandscape
Set drawingViews1 = drawingSheet1.Views
Set drawingView1 = drawingViews1.Add("AutomaticNaming")
Set drawingViewGenerativeLinks1 = drawingView1.GenerativeLinks
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
drawingViewGenerativeLinks1.AddLink body1
drawingViewGenerativeBehavior1.DefineFrontView 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000
drawingView1.x = 594.500000
drawingView1.y = 420.500000
drawingView1.Scale = 1.000000
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
drawingViewGenerativeBehavior1.Update
drawingView1.Activate
End Sub
---------------------------------------------------------------------------------------------------