Inventor Customization

Inventor Customization

Reply
Valued Contributor
LSA-skan
Posts: 95
Registered: ‎08-09-2012
Message 1 of 12 (825 Views)
Accepted Solution

Change the LOD in derived part through iLogic

825 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)

Hi,

 

You don't have to put anyhing in () in line below, the BreakLinkToFile is a method without any arguments.

 

oDerivedAssembly.BreakLinkToFile()

 

-Ishwar

 

Valued Contributor
LSA-skan
Posts: 95
Registered: ‎08-09-2012
Message 2 of 12 (812 Views)

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

Distinguished Contributor
ADNpati
Posts: 125
Registered: ‎07-01-2012
Message 3 of 12 (798 Views)

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 -

-------------------------------------------------------------------------------------
Employee
nagwani
Posts: 33
Registered: ‎11-17-2011
Message 4 of 12 (793 Views)

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()

Distinguished Contributor
ADNpati
Posts: 125
Registered: ‎07-01-2012
Message 5 of 12 (789 Views)

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 -

-------------------------------------------------------------------------------------
Employee
nagwani
Posts: 33
Registered: ‎11-17-2011
Message 6 of 12 (783 Views)

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

Valued Contributor
LSA-skan
Posts: 95
Registered: ‎08-09-2012
Message 7 of 12 (778 Views)

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

Valued Contributor
LSA-skan
Posts: 95
Registered: ‎08-09-2012
Message 8 of 12 (778 Views)

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:

 

Employee
nagwani
Posts: 33
Registered: ‎11-17-2011
Message 9 of 12 (771 Views)

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

Valued Contributor
LSA-skan
Posts: 95
Registered: ‎08-09-2012
Message 10 of 12 (766 Views)

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()

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.