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: 

fatal error when trying to update IProperty

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
230 Views, 7 Replies

fatal error when trying to update IProperty

Hi All, From inside my default.ivb I am trying to update an iProperty in the DocumentChange event. On the statement: oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale I receive a Pur Virtual Function Call error and Inventor crashes. I've tried creating a new drawing and installing the latest patches. I'm using version 8. Any guidance would be appreciated. My hands are tied here. Here is my code: Public Sub UpdateIProperties(ByRef Field As String) Dim i As Integer Dim oPropsets As PropertySets Set oPropsets = ThisApplication.ActiveDocument.PropertySets Select Case Field Case "SCALE" For i = 1 To oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Count If UCase(oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Name) = "SCALE" Then oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale DoEvents End If Next Case Else 'do nothing End Select Set oPropsets = Nothing End Sub
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

This works in an IVB for me Public Sub UpdateIProperties() Dim oDoc As Document Dim i As Integer Dim oPropsets As PropertySets Set oDoc = ThisApplication.ActiveDocument Set oPropsets = oDoc.PropertySets For i = 1 To oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Count If UCase(oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Name) = "SCALE" Then oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale DoEvents End If Next Set oPropsets = Nothing End Sub You did rememebr to have a drawing view right? -- Sean Dotson, PE Autodesk Inventor Certified Expert http://www.sdotson.com Check the Inventor FAQ for most common questions www.sdotson.com/faq.html ----------------------------------------------------------------------- "Mike Rand" wrote in message news:4072fc47_3@newsprd01... Hi All, From inside my default.ivb I am trying to update an iProperty in the DocumentChange event. On the statement: oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale I receive a Pur Virtual Function Call error and Inventor crashes. I've tried creating a new drawing and installing the latest patches. I'm using version 8. Any guidance would be appreciated. My hands are tied here. Here is my code: Public Sub UpdateIProperties(ByRef Field As String) Dim i As Integer Dim oPropsets As PropertySets Set oPropsets = ThisApplication.ActiveDocument.PropertySets Select Case Field Case "SCALE" For i = 1 To oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Count If UCase(oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Name) = "SCALE" Then oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale DoEvents End If Next Case Else 'do nothing End Select Set oPropsets = Nothing End Sub
Message 3 of 8
Anonymous
in reply to: Anonymous

Wow, that works for you? I've tried it on 2 workstations and both crashed. Further to that. Will I need to use FlushToFile to save the iProperty from within Inventor os is it not necessary? So, I guess the code is ok, as I suspected, since it's not generating a normal runtime error. Where can I get some help to figure out why I'm receiving this fatal error? I run this code with an IDW as the active document. Thx Sean "Sean Dotson" wrote in message news:4072fe30_1@newsprd01... This works in an IVB for me Public Sub UpdateIProperties() Dim oDoc As Document Dim i As Integer Dim oPropsets As PropertySets Set oDoc = ThisApplication.ActiveDocument Set oPropsets = oDoc.PropertySets For i = 1 To oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Count If UCase(oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Name) = "SCALE" Then oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale DoEvents End If Next Set oPropsets = Nothing End Sub You did rememebr to have a drawing view right? -- Sean Dotson, PE Autodesk Inventor Certified Expert http://www.sdotson.com Check the Inventor FAQ for most common questions www.sdotson.com/faq.html ----------------------------------------------------------------------- "Mike Rand" wrote in message news:4072fc47_3@newsprd01... Hi All, From inside my default.ivb I am trying to update an iProperty in the DocumentChange event. On the statement: oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale I receive a Pur Virtual Function Call error and Inventor crashes. I've tried creating a new drawing and installing the latest patches. I'm using version 8. Any guidance would be appreciated. My hands are tied here. Here is my code: Public Sub UpdateIProperties(ByRef Field As String) Dim i As Integer Dim oPropsets As PropertySets Set oPropsets = ThisApplication.ActiveDocument.PropertySets Select Case Field Case "SCALE" For i = 1 To oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Count If UCase(oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Name) = "SCALE" Then oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale DoEvents End If Next Case Else 'do nothing End Select Set oPropsets = Nothing End Sub
Message 4 of 8
avbuiten
in reply to: Anonymous

I tried this in Inv7 without any problem
Public Sub UpdateIProperties(ByRef Field As String)
Dim i As Integer
Dim oPropsets As PropertySets
Dim oPropSet As PropertySet

Set oPropsets = ThisApplication.ActiveDocument.PropertySets

Select Case UCase(Field)
Case "SCALE"
' Set oPropSet = oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Set oPropSet = oPropsets.Item("User Defined Properties")
For i = 1 To oPropSet.Count
If UCase(oPropSet.Item(i).Name) = "SCALE" Then
oPropSet.Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale
DoEvents
End If
Next
Case Else
'do nothing
End Select

Set oPropsets = Nothing
End Sub
Message 5 of 8
avbuiten
in reply to: Anonymous

Maybe it's related to the OnChangeEvent?
Message 6 of 8
Anonymous
in reply to: Anonymous

The FlushToFile method is only available from Apprentice. -------------------------------------------------------------------------------- Brian R. Iwaskewycz Senior Mechanical Engineer PA Transformer Technology, Inc. "Well then, my goal becomes clear. The broccoli must DIE..." Will I need to use FlushToFile to save the iProperty from within Inventor os is it not necessary?
Message 7 of 8
Anonymous
in reply to: Anonymous

I don't know if it has anything to do with your crash, but you can replace this: For i = 1 To oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Count If UCase(oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Name) = "SCALE" Then oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale End If Next i with: oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item("Scale").Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale IOW, you don't need to loop through the custom properties looking for the one whose name is "Scale". You can access it directly. -------------------------------------------------------------------------------- Brian R. Iwaskewycz Senior Mechanical Engineer PA Transformer Technology, Inc. "Well then, my goal becomes clear. The broccoli must DIE..." "Mike Rand" wrote in message news:4072fc47_3@newsprd01... Hi All, From inside my default.ivb I am trying to update an iProperty in the DocumentChange event. On the statement: oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale I receive a Pur Virtual Function Call error and Inventor crashes. I've tried creating a new drawing and installing the latest patches. I'm using version 8. Any guidance would be appreciated. My hands are tied here. Here is my code: Public Sub UpdateIProperties(ByRef Field As String) Dim i As Integer Dim oPropsets As PropertySets Set oPropsets = ThisApplication.ActiveDocument.PropertySets Select Case Field Case "SCALE" For i = 1 To oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Count If UCase(oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Name) = "SCALE" Then oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale DoEvents End If Next Case Else 'do nothing End Select Set oPropsets = Nothing End Sub
Message 8 of 8
Anonymous
in reply to: Anonymous

Hmmm, still receiving the error. Could someone try running the code from the Document or Application OnChange event, and see if it crashes Inventor. I'm at a roadblock here.... thx "Mike Rand" wrote in message news:4072fc47_3@newsprd01... Hi All, From inside my default.ivb I am trying to update an iProperty in the DocumentChange event. On the statement: oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale I receive a Pur Virtual Function Call error and Inventor crashes. I've tried creating a new drawing and installing the latest patches. I'm using version 8. Any guidance would be appreciated. My hands are tied here. Here is my code: Public Sub UpdateIProperties(ByRef Field As String) Dim i As Integer Dim oPropsets As PropertySets Set oPropsets = ThisApplication.ActiveDocument.PropertySets Select Case Field Case "SCALE" For i = 1 To oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Count If UCase(oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Name) = "SCALE" Then oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item(i).Value = ThisApplication.ActiveDocument.Sheets(1).DrawingViews.Item(1).Scale DoEvents End If Next Case Else 'do nothing End Select Set oPropsets = Nothing End Sub

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

Post to forums  

Autodesk Design & Make Report