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: 

Document Problems with OnSave Addin

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
202 Views, 5 Replies

Document Problems with OnSave Addin

I trigger a sub with an OnSave event. The class module looks like:

Option Explicit

Implements ApplicationAddInServer
Private WithEvents ApplicationEvents As ApplicationEvents
Private WithEvents oButtonHandler1 As ButtonDefinitionHandler

Private Sub ApplicationAddInServer_Activate(ByVal AddInSiteObject As
Inventor.ApplicationAddInSite, ByVal FirstTime As Boolean)

Set oApp = AddInSiteObject.Application
Set ApplicationEvents = oApp.ApplicationEvents

End Sub

Private Property Get ApplicationAddInServer_Automation() As Object
Set ApplicationAddInServer_Automation = Nothing
End Property

Private Sub ApplicationAddInServer_Deactivate()
Set oApp = Nothing
End Sub

Private Sub ApplicationAddInServer_ExecuteCommand(ByVal CommandID As Long)
'
End Sub

Private Sub ApplicationEvents_OnSaveDocument(ByVal DocumentObject As
Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
NameValueMap, HandlingCode As HandlingCodeEnum)
If BeforeOrAfter = kBefore Then
ChangeProps.Change
End If
End Sub

Then my ChangeProps.Change sub looks like

Option Explicit

Dim oApp2 As Inventor.Application
Dim oDoc As Inventor.Document
Dim oPropsets As PropertySets
Dim oPropSet As PropertySet

Public Sub Change()

Set oDoc = oApp2.ActiveDocument
Set oPropsets = oDoc.PropertySets

_____________


It bombs out on the set oDoc = oApp2.ActiveDocument line... is it not an
active document if it's being saved... Or just a dumb mistake on my part..?
I used oApp 2 as oApp was already defined as a AddInSiteObject.Application
above. Maybe I'm just totally confused...

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
-----------------------------------------------------------------------
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Sean

Have you "Set" oApp2 somewhere? I don't see it in this code

--
Kent
Assistant Moderator
Autodesk Discussion Forum Moderator Program


"Sean Dotson" wrote in message
news:BAC267BE5E704581DDCB870A82963B21@in.WebX.maYIadrTaRb...
> I trigger a sub with an OnSave event. The class module looks like:
>
>
> It bombs out on the set oDoc = oApp2.ActiveDocument line... is it not an
> active document if it's being saved... Or just a dumb mistake on my part..?
> I used oApp 2 as oApp was already defined as a AddInSiteObject.Application
> above. Maybe I'm just totally confused...
>
> --
> Sean Dotson, PE
> http://www.sdotson.com
> Check the Inventor FAQ for most common questions
> www.sdotson.com/faq.html
> -----------------------------------------------------------------------
>
>
Message 3 of 6
Anonymous
in reply to: Anonymous

oops forgot that line when cleaning up the code. I had set it to

Set oApp2 = Inventor.ThisApplication

and it give me a ActiveX component cannot create object error on that
line...

Even if I skip oApp and set

Set oDoc = ThisApplication.ActiveDocument

It gives me the same error..

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
-----------------------------------------------------------------------
"Kent Keller" wrote in message
news:EBACE65D3E19093F98707E61A498E62A@in.WebX.maYIadrTaRb...
> Sean
>
> Have you "Set" oApp2 somewhere? I don't see it in this code
>
> --
> Kent
> Assistant Moderator
> Autodesk Discussion Forum Moderator Program
>
>
> "Sean Dotson" wrote in message
> news:BAC267BE5E704581DDCB870A82963B21@in.WebX.maYIadrTaRb...
> > I trigger a sub with an OnSave event. The class module looks like:
> >
> >
> > It bombs out on the set oDoc = oApp2.ActiveDocument line... is it not an
> > active document if it's being saved... Or just a dumb mistake on my
part..?
> > I used oApp 2 as oApp was already defined as a
AddInSiteObject.Application
> > above. Maybe I'm just totally confused...
> >
> > --
> > Sean Dotson, PE
> > http://www.sdotson.com
> > Check the Inventor FAQ for most common questions
> > www.sdotson.com/faq.html
> > -----------------------------------------------------------------------
> >
> >
>
>
Message 4 of 6
Anonymous
in reply to: Anonymous

I am confused now. 8^)
If this is a Addin then I don't think you can use "ThisApplication"

To my limited knowledge you have to use something like this

Set oApp2 = AddInSiteObject.Application
--
Kent
Assistant Moderator
Autodesk Discussion Forum Moderator Program


"Sean Dotson" wrote in message
news:0E78CDD7758411AFB3143C57D5C89D82@in.WebX.maYIadrTaRb...
> oops forgot that line when cleaning up the code. I had set it to
>
> Set oApp2 = Inventor.ThisApplication
>
> and it give me a ActiveX component cannot create object error on that
> line...
>
> Even if I skip oApp and set
>
> Set oDoc = ThisApplication.ActiveDocument
>
> It gives me the same error..
Message 5 of 6
Anonymous
in reply to: Anonymous

nope.. with

Set oApp2 = AddInSiteObject.Application

I get a Variable Not Defined on AddInSiteObject

Not sure why the old fashioned Inventor.ThisApplication won't work as I used
it in my iProperties Wizard

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
-----------------------------------------------------------------------
"Kent Keller" wrote in message
news:B37CED84A44589D550D818808BC0AB1C@in.WebX.maYIadrTaRb...
> I am confused now. 8^)
> If this is a Addin then I don't think you can use "ThisApplication"
>
> To my limited knowledge you have to use something like this
>
> Set oApp2 = AddInSiteObject.Application
> --
> Kent
> Assistant Moderator
> Autodesk Discussion Forum Moderator Program
>
>
> "Sean Dotson" wrote in message
> news:0E78CDD7758411AFB3143C57D5C89D82@in.WebX.maYIadrTaRb...
> > oops forgot that line when cleaning up the code. I had set it to
> >
> > Set oApp2 = Inventor.ThisApplication
> >
> > and it give me a ActiveX component cannot create object error on that
> > line...
> >
> > Even if I skip oApp and set
> >
> > Set oDoc = ThisApplication.ActiveDocument
> >
> > It gives me the same error..
>
>
Message 6 of 6
Anonymous
in reply to: Anonymous

OK, not sure how but I got it working. I think I had an extra oApp declared
somewhere...

Thanks for the help regardless.

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
-----------------------------------------------------------------------
"Sean Dotson" wrote in message
news:A2BBE0E232ED2E125B37B7582ED249F7@in.WebX.maYIadrTaRb...
> nope.. with
>
> Set oApp2 = AddInSiteObject.Application
>
> I get a Variable Not Defined on AddInSiteObject
>
> Not sure why the old fashioned Inventor.ThisApplication won't work as I
used
> it in my iProperties Wizard
>
> --
> Sean Dotson, PE
> http://www.sdotson.com
> Check the Inventor FAQ for most common questions
> www.sdotson.com/faq.html
> -----------------------------------------------------------------------
> "Kent Keller" wrote in message
> news:B37CED84A44589D550D818808BC0AB1C@in.WebX.maYIadrTaRb...
> > I am confused now. 8^)
> > If this is a Addin then I don't think you can use "ThisApplication"
> >
> > To my limited knowledge you have to use something like this
> >
> > Set oApp2 = AddInSiteObject.Application
> > --
> > Kent
> > Assistant Moderator
> > Autodesk Discussion Forum Moderator Program
> >
> >
> > "Sean Dotson" wrote in message
> > news:0E78CDD7758411AFB3143C57D5C89D82@in.WebX.maYIadrTaRb...
> > > oops forgot that line when cleaning up the code. I had set it to
> > >
> > > Set oApp2 = Inventor.ThisApplication
> > >
> > > and it give me a ActiveX component cannot create object error on that
> > > line...
> > >
> > > Even if I skip oApp and set
> > >
> > > Set oDoc = ThisApplication.ActiveDocument
> > >
> > > It gives me the same error..
> >
> >
>
>

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

Post to forums  

Autodesk Design & Make Report