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: 

Change the LOD in derived part through iLogic

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
LSA-skan
1938 Views, 11 Replies

Change the LOD in derived part through iLogic

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)
11 REPLIES 11
Message 2 of 12
LSA-skan
in reply to: LSA-skan

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

 

/LSA-Skan

Message 3 of 12
ADNpati
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 -

-------------------------------------------------------------------------------------
Message 4 of 12
nagwani
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()

Message 5 of 12
ADNpati
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 -

-------------------------------------------------------------------------------------
Message 6 of 12
nagwani
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

Message 7 of 12
LSA-skan
in reply to: nagwani

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

Message 8 of 12
LSA-skan
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.. 🙂

 

Message 9 of 12
nagwani
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

Message 10 of 12
LSA-skan
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 🙂

 

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

Message 11 of 12
nagwani
in reply to: LSA-skan

Hi,

 

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

 

oDerivedAssembly.BreakLinkToFile()

 

-Ishwar

 

Message 12 of 12
LSA-skan
in reply to: nagwani

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

 

oDerivedAssembly..BreakLinkToFile() = 😞

 

oDerivedAssembly.BreakLinkToFile() = 🙂

 

Thanks again.. 😄

 

your post is accepted as a solution..!

 

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

Post to forums  

Autodesk Design & Make Report