hi,
please check attachment. I got this run-time error message when i tried to add base view from vba.
It happens occasionly.
I am using inventor 2013 and window 7. all updates are installed.
thanks.
Could you please post your vba-code sample + the simplest dataset that would help us reproduce your problem.
Thanks,
'Add base drawingview
Dim oStartPosition As Point2d
Set oStartPosition = oTG.CreatePoint2d(X, Y)
Dim oBaseView As DrawingView
Set oBaseView = oDrawingViews.AddBaseView(oDoc, oStartPosition, 1, kDefaultViewOrientation, kHiddenLineDrawingViewStyle)
I am using inventor 2013. all parts and assmebly are in invetor 2013 format.
thanks.
Could you please try this test (It assumes
that the file "C:\temp\testpart.ipt" exists):
Public Sub AddBaseView_test() ' 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 Dim strFullFilename As String strFullFilename = "C:\temp\testpart.ipt" Dim oModel As Inventor.Document Set oModel = ThisApplication.Documents.Open(strFullFilename, False) ' Create the placement point object. Dim oPoint As Point2d Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(10, 10) ' Create a base view. Dim oBaseView As DrawingView Set oBaseView = oSheet.DrawingViews.AddBaseView( _ oModel, oPoint, 1, _ kIsoTopLeftViewOrientation, _ kHiddenLineRemovedDrawingViewStyle) Call oModel.Close(True) Beep End SubCheers,
the code works fine. except the error on one line. please check attachment.
i mentioned it before. my code works well sometimes just occautionly failing.
thanks.
OK, let's try to open the model in a visible mode.
Public Sub AddBaseView_test() ' 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 Dim strFullFilename As String strFullFilename = "C:\temp\testpart.ipt" Dim oModel As Inventor.Document Set oModel = ThisApplication.Documents.Open(strFullFilename, True) ' Create the placement point object. Dim oPoint As Point2d Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(10, 10) ' Create a base view. Dim oBaseView As DrawingView Set oBaseView = oSheet.DrawingViews.AddBaseView( _ oModel, oPoint, 1, _ kIsoTopLeftViewOrientation, _ kHiddenLineRemovedDrawingViewStyle) Beep End Sub.
Any troubles?
cheers,
What if you are closing the model while drawing update is not completed yet?
Please look at this post:
hi,
i tried setting from that website. it is not working. Can I send you macro? so you can test it. The error is adding baseview when I use it with part or sheetmetal part.
thanks.
please check attachment. test macro with sheetmetal part or part model, it gave "run-time" error.
Hi,
I had the similar problem for assemblies.Try to use next file name definition:
strFullFilename = "C:\temp\testpart.ipt"
strFullFilename= ThisApplication.FileManager.GetFullDocumentName(strFullFilename, "myLODR")
where "myLODR" is your(Custom) desired Level of Detail Representation.
Dear Bezdar, you are right - working with assemblies with custom LODs we need to specify full document name.
The code published by jcneal in the previous post (GeneralDrawings.zip) works fine on my side when sheetmetal part or part model is an active document.
hi, thanks for your replay. Below is what i did.
Open inventor--open a part--run the macro (generaldrawing)--run time error
Open inventor--open an assembly--run the macro--good---open a part--run the macro---good
I have not gotten the error behind it.
sincerely regards,
sky