Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drawing view from part body

Status
Not open for further replies.

Alan Lowbands

Aerospace
May 17, 2017
274
GB
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

---------------------------------------------------------------------------------------------------
 
Replies continue below

Recommended for you

the line bellow define the H and V vectors for the view

Code:
drawingViewGenerativeBehavior1.DefineFrontView 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000

So in order to control this you need to ask the user to select a planar face using SelectElement2 and filter and get some directions from the face. This is where you will have to be creative... You could use theMeasurable on the plane and get first and second direction... please check V5automation.chm file in your code/bin/ install directory

Eric N.
indocti discant et ament meminisse periti
 
Thanks itsmyjob,
I'll have a go :)
If the parts hadn't been on the component axis it wouldn't be a problem but the views are coming in like an iso view :)
I'll try and sus it out
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top