Thank you for your welcome and for your help.
However, I did not understand how to program macro for catia for drafting ambient.
I began the record, I set the drafting, a casual front and a casual section.
This is the code:
"
Code:
Language="VBSCRIPT"
Sub CATMain()
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim drawingDocument1 As Document
Set drawingDocument1 = documents1.Add("Drawing")
drawingDocument1.Standard = catISO
Dim drawingSheets1 As DrawingSheets
Set drawingSheets1 = drawingDocument1.Sheets
Dim drawingSheet1 As DrawingSheet
Set drawingSheet1 = drawingSheets1.Item("Foglio.1")
drawingSheet1.PaperSize = catPaperA0
drawingSheet1.Scale = 1.000000
drawingSheet1.Orientation = catPaperLandscape
Dim drawingViews1 As DrawingViews
Set drawingViews1 = drawingSheet1.Views
Dim drawingView1 As DrawingView
Set drawingView1 = drawingViews1.Add("AutomaticNaming")
Dim drawingViewGenerativeLinks1 As DrawingViewGenerativeLinks
Set drawingViewGenerativeLinks1 = drawingView1.GenerativeLinks
Dim drawingViewGenerativeBehavior1 As DrawingViewGenerativeBehavior
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
Dim partDocument1 As Document
Set partDocument1 = documents1.Item("Part1.CATPart")
Dim product1 As CATBaseDispatch
Set product1 = partDocument1.GetItem("Part1")
drawingViewGenerativeBehavior1.Document = product1
drawingViewGenerativeBehavior1.DefineFrontView 0.809714, -0.465847, -0.356860, -0.586824, -0.642788, -0.492404
drawingView1.x = 594.500000
drawingView1.y = 420.500000
drawingView1.Scale = 1.000000
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
drawingViewGenerativeBehavior1.Update
drawingView1.Activate
Set drawingDocument1 = CATIA.ActiveDocument
Set drawingSheets1 = drawingDocument1.Sheets
Set drawingSheet1 = drawingSheets1.ActiveSheet
Set drawingViews1 = drawingSheet1.Views
Set drawingView1 = drawingViews1.ActiveView
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
Dim drawingView2 As DrawingView
Set drawingView2 = drawingViews1.Add("AutomaticNaming")
Dim drawingViewGenerativeBehavior2 As DrawingViewGenerativeBehavior
Set drawingViewGenerativeBehavior2 = drawingView2.GenerativeBehavior
drawingView2.x = 338.903315
drawingView2.y = 605.738502
Dim double1 As Double
double1 = drawingView1.Scale
drawingView2.Scale = 1.000000
Dim double2 As Double
double2 = drawingView1.Angle
drawingView2.Angle = 0.000000
[COLOR=#CC0000]Dim arrayOfVariantOfDouble1(3)
arrayOfVariantOfDouble1(0) = 46.166950
arrayOfVariantOfDouble1(1) = 63.702304
arrayOfVariantOfDouble1(2) = -68.664461
arrayOfVariantOfDouble1(3) = -94.744928[/color]
drawingViewGenerativeBehavior2.DefineSectionView arrayOfVariantOfDouble1, "SectionCut", "Offset", 0, drawingViewGenerativeBehavior1
Dim drawingViewGenerativeLinks2 As DrawingViewGenerativeLinks
Set drawingViewGenerativeLinks2 = drawingView2.GenerativeLinks
Set drawingViewGenerativeLinks1 = drawingView1.GenerativeLinks
drawingViewGenerativeLinks1.CopyLinksTo drawingViewGenerativeLinks2
Set drawingViewGenerativeBehavior2 = drawingView2.GenerativeBehavior
drawingViewGenerativeBehavior2.Update
drawingView2.ReferenceView = drawingView1
drawingView2.AlignedWithReferenceView
End Sub
"
In the macro that I built (this is not represented!), I have got an array in which there are the coordinates of the different sections (the
arrayofdouble above).
I want to do something like:
For i = 0 To n (i=index of intersection, n=total of sections)
arrayOfVariantOfDouble(i) = ...
arrayOfVariantOfDouble(i+1) = ...
arrayOfVariantOfDouble(i+2) = ...
arrayOfVariantOfDouble(i+3) = ...
Next
And positioning the different sections along rows and columns.
I see a lot of code that I don't get, such as
Code:
Dim drawingViewGenerativeLinks2 As DrawingViewGenerativeLinks
Set drawingViewGenerativeLinks2 = drawingView2.GenerativeLinks
Set drawingViewGenerativeLinks1 = drawingView1.GenerativeLinks
drawingViewGenerativeLinks1.CopyLinksTo drawingViewGenerativeLinks2
Set drawingViewGenerativeBehavior2 = drawingView2.GenerativeBehavior
drawingViewGenerativeBehavior2.Update
Which part I must include in the loop, for avoiding a lot of redudant objects? (ex: drawingViewGenerativeBehavior2-3-4-5-6-7-...-n , one for section).
One last question: are you sure that (drawingView).x/y is a method that sets the position of the CENTER of the view? Because sometimes it seems it is not the center...