Hi!
I'm working on a program where i'd like to take an assembly, open a part of it, and through a macro automaticaly export that part to an IDW. I already have a program where i take the part and export it to the idw, but on my program i must identify the path of the part. Does anybody know how to use the part that it's already loaded on inventor? When you create a new idw, if you've an openned part it automaticaly loads on the base view. I'd like to do the same.
Best Regards
Nivaldo.
Solved! Go to Solution.
Solved by philippe.leefsma. Go to Solution.
Hi Nivaldo,
There are several ways to access a loaded document, it depends from where you want to retrieve it. The Application.ActiveDocument will return the document that is currently visible in the UI. If you work with an assembly, you can access the document that a specific occurrence is referencing using "AssemblyComponentDefinition.Occurrences(idx).Definition.Document".
Without a bit more context, it is hard to give you a more detailed answer.
Regards,
Philippe.
Thanks Philippe!
It helped a lot.
I've found another way to do the same thing i was trying to do, but without use the document which is already oppened.
Through a saving comand i created a a temporary file of the part in a folder and used that file with a standard name and path to create my IDW. It works well too, but running that it takes a little bit more of time until it creates the temp. part.
That's the program i created:
'Salvar a peça em uma pasta temporária para importação no IDW / Save the part as a Temporary Part in a especific folder
Dim invApp As Inventor.Application
Set invApp = ThisApplication
'invApp.SilentOperation = True
Dim iptDoc As Inventor.PartDocument
Set iptDoc = invApp.ActiveDocument
Dim iptFile As String
LaserDir = "c:\temp\Macro\"
iptFile = LaserDir + "Temp.ipt"
With invApp.CommandManager
Call .PostPrivateEvent(kFileNameEvent, iptFile)
Call .StartCommand(kFileSaveCopyAsCommand)
End With
Set iptDoc = Nothing
'invApp.SilentOperation = False
Set invApp = Nothing
' Criar um novo documento baseando-se no Template padrão / Create a new document based on the standard template
Dim oDrawnDoc As DrawingDocument
Set oDrawnDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kDrawingDocumentObject))
'************Plotar a peça salva em um arquivo do IDW / Use the temporary part on the IDW
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
'Set a reference to the active sheet.
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
' Create a new NameValueMap object
Dim oBaseViewOptions As NameValueMap
Set oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Open the model document (corresponding to the "MyLODRep" representation).
Dim Abc As String
Abc = ThisApplication.FileManager.GetFullDocumentName("C:\Temp\Macro\Temp.ipt")
Dim oModel As Document
Set oModel = ThisApplication.Documents.Open(Abc, False)
' Create the placement point object.
Dim oPoint As Point2D
Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(10, 25)
' Create a base view.
Dim oBaseView As DrawingView
Set oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 0.5, kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle, , , oBaseViewOptions)
Can't find what you're looking for? Ask the community or share your knowledge.