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.. 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..
'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)
Solved! Go to Solution.
Solved! by nagwani. See the answer in context.
You don't have to put anyhing in () in line below, the BreakLinkToFile is a method without any arguments.
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
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
oDerivedAssembly = oPartDoc.ComponentDefinition.ReferenceComponents.D
' Break the link
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.LevelOfDetailRepresent
And Breaking link is straight process.
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.
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..?
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..
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.
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..:
Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.