• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    Contributor
    stancernak
    Posts: 12
    Registered: ‎01-12-2011

    Object Default Style change

    278 Views, 2 Replies
    01-17-2011 07:26 AM

     

    Hi everybody,

     

    I am using Inventor version 2011. I wrote this code which tells me which object defaults style is active

     

    Public Sub ActiveObjectDefaults()

     

        Dim oDocument As DrawingDocument

        Set oDocument = ThisApplication.ActiveDocument

     

        Dim DrgStMgr As DrawingStylesManager

        Set DrgStMgr = oDocument.StylesManager

     

        Dim ObjDfStyle As Style

        Set ObjDfStyle = DrgStMgr.ActiveStandardStyle.ActiveObjectDefaults

     

        MsgBox ObjDfStyle.Name

     

    End Sub

     

    Is it possible to change Active Object Defaults Style by VBA code (see picture below)?

     

    Object Defaults.JPG

     

    I am trying to change Object Defaults in order to temporarily switch style which use layers with different lineweights, and than switch it back. I am new to VBA so I am not sure if I am not trying to do something what is impossible.

     

    Thanks for any respond.

     

     

    ----------------------
    Stan Cernak
    Please use plain text.
    Active Contributor
    andrewwhiteinc
    Posts: 50
    Registered: ‎02-02-2011

    Re: Object Default Style change

    02-26-2012 09:27 AM in reply to: stancernak

    Hey Guys, I'm also looking for the answer to this too please

    P. Andrew White,EIT
    Engineer-in-Training, Industrial Automation
    Please use plain text.
    Contributor
    stancernak
    Posts: 12
    Registered: ‎01-12-2011

    Re: Object Default Style change

    02-27-2012 12:30 AM in reply to: andrewwhiteinc

    I already managed to change it by using code below.

     

    Public Sub ChangeObjDefaults()
    
        'set active document as drawing document
        Dim oDrgDoc As DrawingDocument
        Set oDrgDoc = ThisApplication.ActiveDocument
           
        Dim oDrgStlMgr As DrawingStylesManager
        Set oDrgStlMgr = oDrgDoc.StylesManager
        
        Dim oObjDfStl As ObjectDefaultsStylesEnumerator
        Set oObjDfStl = oDrgStlMgr.ObjectDefaultsStyles
    
        'set Object Defaults (ISO) as active object default style
        oDrgStlMgr.ActiveStandardStyle.ActiveObjectDefaults = oObjDfStl.Item("Object Defaults (ISO)")
    
    End Sub

     Hope it will help you.

    ----------------------
    Stan Cernak
    Please use plain text.