Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iLogic to Read Current View Representation in Part File

Anonymous

iLogic to Read Current View Representation in Part File

Anonymous
Not applicable

Hi All,

I'm looking for the iLogic code to read which view rep is currently active in a part file so that I can then perform a few mods to the part via IF statements. I can't however find a way to read the active view representation from existing snippets or forum posts. 

Example....

Dim oViewRep as ??????????????????????

If oViewRep = "View1" Then Mods to part... Else Other mods to part....  End If


Any help on reading the existing view rep would be appreciated. 

 

0 Likes
Reply
Accepted solutions (1)
1,424 Views
3 Replies
Replies (3)

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hello, With this code you can read what is the view of active representation in your part or assembly.

 

Dim oDoc As Document = ThisDoc.Document  
Dim oDef As ComponentDefinition = oDoc.ComponentDefinition 

Dim ActViewRep As String = oDef.RepresentationsManager.ActiveDesignViewRepresentation.name
Dim ActPosRep As String = oDef.RepresentationsManager.ActivePositionalRepresentation.name
Dim ActLOD As String = oDef.RepresentationsManager.ActiveLevelOfDetailRepresentation.name

MessageBox.Show(ActViewRep)

 I hope it will be useful to develop what you need. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Anonymous
Not applicable

Thank you for the code! This seems to work for an assembly but not for a part.

I get the following error:

Object variable or With block variable not set.
System.NullReferenceException: Object variable or With block variable not set.
   at Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
   at LmiRuleScript.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
0 Likes

Anonymous
Not applicable

Ignore that! 

Works for parts if I remove the positional and LOD lines since they are not available in an ipt. 

Thank you for the help :slightly_smiling_face:

0 Likes