Change the LOD in derived part through iLogic

Change the LOD in derived part through iLogic

LSA-skan
Advocate Advocate
2,452 Views
11 Replies
Message 1 of 12

Change the LOD in derived part through iLogic

LSA-skan
Advocate
Advocate

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.. Smiley Frustrated 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.. Smiley Happy

 

 

'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)
0 Likes
Accepted solutions (1)
2,453 Views
11 Replies
Replies (11)
Message 2 of 12

LSA-skan
Advocate
Advocate

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

 

/LSA-Skan

0 Likes
Message 3 of 12

Anonymous
Not applicable

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 

0 Likes
Message 4 of 12

nagwani
Alumni
Alumni

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

Message 5 of 12

Anonymous
Not applicable

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.

0 Likes
Message 6 of 12

nagwani
Alumni
Alumni

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

Message 7 of 12

LSA-skan
Advocate
Advocate

Thanks for all your replys

 

The solution you provided Nagwani, worked 🙂

 

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

 

/LSA-Skan

0 Likes
Message 8 of 12

LSA-skan
Advocate
Advocate

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.. 🙂

 

0 Likes
Message 9 of 12

nagwani
Alumni
Alumni

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

0 Likes
Message 10 of 12

LSA-skan
Advocate
Advocate

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 🙂

 

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

0 Likes
Message 11 of 12

nagwani
Alumni
Alumni
Accepted solution

Hi,

 

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

 

oDerivedAssembly.BreakLinkToFile()

 

-Ishwar

 

0 Likes
Message 12 of 12

LSA-skan
Advocate
Advocate

Ahh... i just notced there were 2 dots in the code..

 

oDerivedAssembly..BreakLinkToFile() = 😞

 

oDerivedAssembly.BreakLinkToFile() = 🙂

 

Thanks again.. 😄

 

your post is accepted as a solution..!

 

0 Likes