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

    Autodesk Inventor Customization

    Reply
    Valued Contributor
    Posts: 66
    Registered: ‎08-09-2012
    Accepted Solution

    Change the LOD in derived part through iLogic

    206 Views, 11 Replies
    01-27-2013 11:51 PM

    I got this code earlier from Curtis_Waguespack, and i would like to add a setting...

     

    When i run this rule it Derives the assembly, but LOD is set to Master, i would like it to be set to my own (Configurator) LOD...

     

    I don't seem to be able to find anything in this code, that defines LOD... 

     

    So far im doing ok with the standard ilogic code, but when it´s API or VBA code im lost.. :smileyfrustrated: which leads me to this.. i've been searching the forum back and forth to find a code that performs the feature "Shrinkwrap", and somehow everything i have found so far does not work... even the code example in Inventors help menu under programming help, which several forum posts have suggested... Therefore im trying to solve this with Curtis's code as staring point.. :smileyhappy:

     

     

    'set a reference to the assembly component definintion.'this assumes an assembly document is open.Dim oAsmCompDef As AssemblyComponentDefinition
    oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition    
    
    'define the path and file nameDim sPathandName As String
    sPathandName  = ThisDoc.PathAndFileName(False) 
    
    ' Create a new part file to derive the selected part into 'note: kPartDocumentObject is the default template'you could specifiy a path and file name for a custom templateDim oPartDoc As PartDocument
    oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject)) 
    
    'create the derived assembly deffinitionDim oDerivedAssemblyDef As DerivedAssemblyDefinition 
    oDerivedAssemblyDef = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(sPathandName & ".iam")
    
    'Set derive style optionsoDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyWithSeams
    'options:    'kDeriveAsSingleBodyWithSeams     'kDeriveAsSingleBodyNoSeams     'kDeriveAsMultipleBodies     'kDeriveAsWorkSurface 
    'Create the derived partDim oDerivedAssembly As DerivedAssemblyComponent 
    oDerivedAssembly = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)
    Please use plain text.
    Valued Contributor
    Posts: 66
    Registered: ‎08-09-2012

    Re: Change the LOD in derived part through iLogic

    01-28-2013 01:41 AM in reply to: LSA-skan

    Also, where do i define if the link should be broken, supressed og kept active..?

     

    /LSA-Skan

    Please use plain text.
    Valued Contributor
    Posts: 84
    Registered: ‎07-01-2012

    Re: Change the LOD in derived part through iLogic

    01-28-2013 08:11 PM in reply to: LSA-skan

    If you already have Configurator LOD defined in Assembly then you to load LOD you have to use

     

    Configurator.active i.,e., LOD.Active

     

    ti will pop up save window if there are any changes in previous LOD and loads to required (configuratoe) LOD

     

    Cheers 

    Mechanical Engineer
    Inventor Applications Engineer

    --------------------------------------------------------------------------------------

    If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

    -------------------------------------------------------------------------------------
    Please use plain text.
    Employee
    nagwani
    Posts: 33
    Registered: ‎11-17-2011

    Re: Change the LOD in derived part through iLogic

    01-28-2013 09:19 PM in reply to: LSA-skan

    Hi There,

     

    There is a bug in Inventor API documentation which states that ActiveLevelOfDetailRepresentation is read only property i.e. "Property that returns the name of the active Level of Detail Representation for the derived assembly", but ActiveLevelOfDetailRepresentation can be set as shown below. And you can break the link after Derived assembly is created.

     

    'Set level of Detail

    oDerivedAssemblyDef.ActiveLevelOfDetailRepresentation = "LevelOfDetail1"

     

    oDerivedAssembly = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)..

     

    ' Break the link

    oDerivedAssembly..BreakLinkToFile()

    Please use plain text.
    Valued Contributor
    Posts: 84
    Registered: ‎07-01-2012

    Re: Change the LOD in derived part through iLogic

    01-28-2013 09:36 PM in reply to: nagwani

    Good To see you back on Forms Mr.Ishwar.

     

    This is how i did for a addin for a client and it is workng fine(till)

    is that a good way to activate MasterLOD??

     

    ' Back to Master Level of Detail.
    Dim oMasterLOD As LevelOfDetailRepresentation
    Set oMasterLOD = oDef.RepresentationsManager.LevelOfDetailRepresentations.Item(1)
    oMasterLOD.Activate

     


    And Breaking link is straight process.

    Mechanical Engineer
    Inventor Applications Engineer

    --------------------------------------------------------------------------------------

    If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

    -------------------------------------------------------------------------------------
    Please use plain text.
    Employee
    nagwani
    Posts: 33
    Registered: ‎11-17-2011

    Re: Change the LOD in derived part through iLogic

    01-28-2013 10:30 PM in reply to: ADNpati

    Hi,

     

    Thanks, your code snippet to Activate/Switch to Master LOD is fine. The advantage with specifying LOD during shrinkwrap through ActiveLevelOfDetailRepresentation is that the API takes care of switching to specified LOD and once the derived part is created the LOD is switched backed to Master.

     

    Regards,

    -Ishwar

    Please use plain text.
    Valued Contributor
    Posts: 66
    Registered: ‎08-09-2012

    Re: Change the LOD in derived part through iLogic

    01-28-2013 10:36 PM in reply to: nagwani

    Thanks for all your replys

     

    The solution you provided Nagwani, worked :smileyhappy:

     

    however, due to my inexperience, im not sure what to put in the () in the break link line..?

     

    /LSA-Skan

    Please use plain text.
    Valued Contributor
    Posts: 66
    Registered: ‎08-09-2012

    Re: Change the LOD in derived part through iLogic

    01-28-2013 10:42 PM in reply to: ADNpati

    ADNpati.:

     

    Im not sure why you want to switch back to Master LOD, any specific reason for that..?

     

    The assembly im woking on should always be on my custom LOD, cause the master will not make any sense, due to the overflod of diffrent options being ontop of eachother.. :smileyhappy:

     

    Please use plain text.
    Employee
    nagwani
    Posts: 33
    Registered: ‎11-17-2011

    Re: Change the LOD in derived part through iLogic

    01-28-2013 10:51 PM in reply to: LSA-skan

    Hi,

     

    The derived API would consider current LOD if the ActiveLevelOfDetailRepresentation is not specified. One may have muliple LOD's and if specified LOD is not current LOD, the API takes care of switching to specified LOD and once the derived part is created it swithces to active LOD.

     

    -Ishwar

    Please use plain text.
    Valued Contributor
    Posts: 66
    Registered: ‎08-09-2012

    Re: Change the LOD in derived part through iLogic

    01-28-2013 11:00 PM in reply to: nagwani

    yeah, i think im with you on that... but when i used the code i posted in the original post, it changed to the master LOD regardless of what LOD was active at the time... But when i use Shrinkwrap manually, the derived was set to the Active LOD, hence the need for the line you provided :smileyhappy:

     

    regarding the ealier post about returning to master LOD like ADNpati, i was just wondering if there was some kind of beneficial reason for returning to master LOD..

     

    Could you tell me what to put in the () in..:

     

    oDerivedAssembly..BreakLinkToFile()

    Please use plain text.