Create Flat Pattern DrawingView

Create Flat Pattern DrawingView

Anonymous
Not applicable
367 Views
1 Reply
Message 1 of 2

Create Flat Pattern DrawingView

Anonymous
Not applicable
Hi!

I'm trying to create a drawing view from the sheet metal flat pattern.

When I play the routine it gives error when adding the BASEVIEW!

Could anyone tell me parameters should I change in the add drawing view command

*********************
Sub Vistas2()
Debug.Print Chr(13) & "******* - Sub Vistas - *******************"

' Declaração do objecto da Aplicação
Dim oApplication As Inventor.Application

' Assume que o Autodesk Inventor está a ser executado
Set oApplication = GetObject(, "Inventor.Application")

Dim oActiveDoc As Document
Dim PathActiveDoc As String

Set oActiveDoc = ThisApplication.ActiveDocument
oActiveDoc.Activate
Debug.Print oActiveDoc.FullFileName
PathActiveDoc = oActiveDoc.FullFileName

Dim Modelo As PartComponentDefinition
Set Modelo = oActiveDoc.ComponentDefinition

Modelo.Unfold
'Modelo.FlatPattern.GetView

oActiveDoc.Close (False)
Set oActiveDoc = ThisApplication.Documents.Open(PathActiveDoc)
oActiveDoc.Activate



'***************************
' Criar um novo Drawing

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject)

' Definir a folha de oDrawDoc
Dim oSheet As Sheet
Set oSheet = oDrawDoc.Sheets.Item(1)

' Definir o ponto para a posição da vista em cm. A vista é colocada pelo o centro de gravidade do modelo.
Dim oPoint1 As Point2d
Set oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(20#, 15#)

' Cria uma projecção através da vista corrente do modelo
Dim oView1 As DrawingView
'***
Set oView1 = oSheet.DrawingViews.AddBaseView(oActiveDoc, oPoint1, 1, kFlatBacksidePivot180ViewOrientation, kHiddenLineRemovedDrawingViewStyle, , , False)
'***

' Define o nome do ficheiro idw a gravar
Dim LenaActiveDoc As Integer
Dim NomeFicheiro As String
LenoActiveDoc = Len(PathActiveDoc) - 4
NomeFicheiro = Left(PathActiveDoc, LenoActiveDoc)

NomeFicheiro = NomeFicheiro & ".idw"
Debug.Print "Nome do ficheiro de oDrawDoc criado - " & NomeFicheiro

' Grava o ficheiro idw
Call oDrawDoc.SaveAs(NomeFicheiro, True)
oDrawDoc.update
' Fecha o ficheiro idw
oDrawDoc.Close (True)

Debug.Print " *********** - Fim sub Vistas - ********** " & Chr(13)
End Sub

*******************************

Thanks!

Telmo Oliveira
0 Likes
368 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
You are closing the active Document object (oActiveDoc) too soon. When the
code reaches the AddBaseView call, the sheet metal document is not available
to create the view so the oActiveDoc variable is probably invalid.

Also, in order to create the flat pattern view instead of the folded model
view, you need to specify a boolean option in the AdditionalOptions argument
of the AddBaseView method. Here is the description of the argument from
programming help...

AdditionalOptions

Optional input NameValueMap object that specifies additional or advanced
options. The options currently supported include:

Name Value Type Valid document type
WeldmentFeatureGroup WeldmentFeatureGroupEnum Weldment
SheetMetalFoldedModel Boolean Sheet Metal
DesignViewRepresentation String Assembly
DesignViewAssociative Boolean Assembly
PositionalRepresentation String Assembly
MemberName String Part, Assembly


SheetMetalFoldedModel As Boolean
If the model document type is a sheet metal part, this option specifies if
the view is to be created from the folded model (True) or the flattened
model (False). The default value if not specified is to display the folded
model. This option is ignored if the model document is not a sheet metal
part.

Sanjay-



wrote in message
news:5550507@discussion.autodesk.com...
Hi!

I'm trying to create a drawing view from the sheet metal flat pattern.

When I play the routine it gives error when adding the BASEVIEW!

Could anyone tell me parameters should I change in the add drawing view
command

*********************
Sub Vistas2()
Debug.Print Chr(13) & "******* - Sub Vistas - *******************"

' Declaração do objecto da Aplicação
Dim oApplication As Inventor.Application

' Assume que o Autodesk Inventor está a ser executado
Set oApplication = GetObject(, "Inventor.Application")

Dim oActiveDoc As Document
Dim PathActiveDoc As String

Set oActiveDoc = ThisApplication.ActiveDocument
oActiveDoc.Activate
Debug.Print oActiveDoc.FullFileName
PathActiveDoc = oActiveDoc.FullFileName

Dim Modelo As PartComponentDefinition
Set Modelo = oActiveDoc.ComponentDefinition

Modelo.Unfold
'Modelo.FlatPattern.GetView

oActiveDoc.Close (False)
Set oActiveDoc = ThisApplication.Documents.Open(PathActiveDoc)
oActiveDoc.Activate



'***************************
' Criar um novo Drawing

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject)

' Definir a folha de oDrawDoc
Dim oSheet As Sheet
Set oSheet = oDrawDoc.Sheets.Item(1)

' Definir o ponto para a posição da vista em cm. A vista é colocada pelo o
centro de gravidade do modelo.
Dim oPoint1 As Point2d
Set oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(20#, 15#)

' Cria uma projecção através da vista corrente do modelo
Dim oView1 As DrawingView
'***
Set oView1 = oSheet.DrawingViews.AddBaseView(oActiveDoc, oPoint1, 1,
kFlatBacksidePivot180ViewOrientation, kHiddenLineRemovedDrawingViewStyle, ,
, False)
'***

' Define o nome do ficheiro idw a gravar
Dim LenaActiveDoc As Integer
Dim NomeFicheiro As String
LenoActiveDoc = Len(PathActiveDoc) - 4
NomeFicheiro = Left(PathActiveDoc, LenoActiveDoc)

NomeFicheiro = NomeFicheiro & ".idw"
Debug.Print "Nome do ficheiro de oDrawDoc criado - " & NomeFicheiro

' Grava o ficheiro idw
Call oDrawDoc.SaveAs(NomeFicheiro, True)
oDrawDoc.update
' Fecha o ficheiro idw
oDrawDoc.Close (True)

Debug.Print " *********** - Fim sub Vistas - ********** " & Chr(13)
End Sub

*******************************

Thanks!

Telmo Oliveira
0 Likes