Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

run-time error when addbaseview

14 REPLIES 14
Reply
Message 1 of 15
skyngu
456 Views, 14 Replies

run-time error when addbaseview

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.

Autodesk Inventor Professional 2019
14 REPLIES 14
Message 2 of 15
Vladimir.Ananyev
in reply to: skyngu

Could you please post your vba-code sample + the simplest dataset  that would help us reproduce your problem.

Thanks,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 15
skyngu
in reply to: Vladimir.Ananyev

'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.

Autodesk Inventor Professional 2019
Message 4 of 15
Vladimir.Ananyev
in reply to: skyngu

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 Sub
Cheers,

Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 5 of 15
skyngu
in reply to: Vladimir.Ananyev

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.

Autodesk Inventor Professional 2019
Message 6 of 15
Vladimir.Ananyev
in reply to: skyngu

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,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 7 of 15
skyngu
in reply to: Vladimir.Ananyev

the code works fine.
Autodesk Inventor Professional 2019
Message 8 of 15
skyngu
in reply to: Vladimir.Ananyev

my problem still exist in inventor 2014 sp2. it fails on addbaseview.
Autodesk Inventor Professional 2019
Message 9 of 15
Vladimir.Ananyev
in reply to: skyngu

What if you are closing the model while drawing update is not completed yet?

Please look at this post:

http://knowledge.autodesk.com/support/inventor-products/troubleshooting/caas/sfdcarticles/sfdcarticl...


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 10 of 15
skyngu
in reply to: Vladimir.Ananyev

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.

Autodesk Inventor Professional 2019
Message 11 of 15
skyngu
in reply to: Vladimir.Ananyev

i tried send an email to ADN. but it reply "case closed".
Autodesk Inventor Professional 2019
Message 12 of 15
skyngu
in reply to: Vladimir.Ananyev

please check attachment. test macro with sheetmetal part or part model, it gave "run-time" error.

Autodesk Inventor Professional 2019
Message 13 of 15
Bezdar
in reply to: skyngu

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.

Message 14 of 15
Vladimir.Ananyev
in reply to: Bezdar

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.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 15 of 15
skyngu
in reply to: Vladimir.Ananyev

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

Autodesk Inventor Professional 2019

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report