Is "master" model state name localized?

Is "master" model state name localized?

nmunro
Collaborator Collaborator
586 Views
8 Replies
Message 1 of 9

Is "master" model state name localized?

nmunro
Collaborator
Collaborator

Can't seem to find an answer to this anywhere. Is the name for the master model state (ModelStateName) changed in localized versions of Inventor?

        


https://c3mcad.com

0 Likes
587 Views
8 Replies
Replies (8)
Message 2 of 9

bradeneuropeArthur
Mentor
Mentor
What do you exactly mean with "changed in localized versions of Inventor"?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 9

nmunro
Collaborator
Collaborator

In a non-English language Inventor version, is "Master" translated to the local equivalent.

        


https://c3mcad.com

0 Likes
Message 4 of 9

Curtis_Waguespack
Consultant
Consultant

Hi @nmunro 

 

I think it would be a different name. And in fact in Inventor 2023 they discarded the name "Master" and use "Primary" for the English versions. I think the safest way to access the "built in" model state is probably via item number as in this example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

	Dim oDoc As AssemblyDocument
	oDoc = ThisApplication.ActiveDocument	    
    
	Dim oModelStates As ModelStates 	
	oModelStates = oDoc.ComponentDefinition.ModelStates 	
	
	'get the built in model state
	oBuilt_In_MS = oModelStates.Item(1)	
	
	MsgBox(oBuilt_In_MS.Name,,"iLogic")

  

EESignature

Message 5 of 9

nmunro
Collaborator
Collaborator

Thanks Curtis, your solution was one on my list. Still would like to know if anyone can check a localized version.

        


https://c3mcad.com

0 Likes
Message 6 of 9

Michael.Navara
Advisor
Advisor

Use string identifiers are common, but bad practice. Use built-in enums instead. It is not culture (language) specific. Here is sample how to detect master model state

 

Dim asm As AssemblyDocument = ThisDoc.Document
Dim activeModelState As ModelState = asm.ComponentDefinition.ModelStates.ActiveModelState
Logger.Debug("Active model stsate is {0}", activeModelState.ModelStateType)
If activeModelState.ModelStateType = ModelStateTypeEnum.kMasterModelStateType Then
	Logger.Debug("Master model state")
End If
0 Likes
Message 7 of 9

bradeneuropeArthur
Mentor
Mentor

Does this help you further?

Dim oDoc As AssemblyDocument
	oDoc = ThisApplication.ActiveDocument	    
    
	Dim oModelStates As ModelStates 	
	oModelStates = oDoc.ComponentDefinition.ModelStates 

	
	Dim ms As Inventor.ModelState
	
	For Each ms In oModelStates
	If ms.ModelStateType = Inventor.ModelStateTypeEnum.kMasterModelStateType Then
			
		MsgBox("Model state Master")
	Else If ms.ModelStateType = Inventor.ModelStateTypeEnum.kCustomModelStateType Then
			
		MsgBox("Model state Custom")	
		
	Else If ms.ModelStateType = Inventor.ModelStateTypeEnum.kSubstituteModelStateType Then
			
		MsgBox("Model state Substitute")
		
	Else If ms.ModelStateType = Inventor.ModelStateTypeEnum.kLastActiveModelStateType Then
			
		MsgBox("Model state Active")
	End If
		Next
	'get the built in model state
	oBuilt_In_MS = oModelStates.Item(1)	

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 8 of 9

CattabianiI
Collaborator
Collaborator

No one mentioned the proper class to manage localization, so I add some links:

 

' Method that returns whether the input primary model state string
' is valid or not. The input primary model state string can be in 
' any language that Inventor supports.
ThisApplication.LanguageTools.IsValidPrimaryModelState(PrimaryName As String) 

 

' Read-only property that returns the primary ModelState string in current language.
ThisApplication.LanguageTools.CurrentPrimaryModelStateString

 

Message 9 of 9

WCrihfield
Mentor
Mentor

Just pointing out another set of ModelState related tools that you (and others) may like.

One of these seems to contain a tool that sounds like an exact match for checking your request.

This appears to be a direct way get the 'localized' version of a supplied ModelState name.

Dim oMSName As String = "Master"
Dim oMSNUtils As New Autodesk.iLogic.Runtime.ModelStateNameUtils
Dim sLocalizedName As String = oMSNUtils.GetLocalizedName(oMSName)
MsgBox("The 'Localized' version of " & oMSName & " is:  " & sLocalizedName, vbInformation, "iLogic")

The main tool being used there (ModelStateNameUtils) could be used without the "Autodesk.iLogic.Runtime" part, but I just added that so others would know where it is being sourced from, but the 'Runtime' source is already referenced for us automatically by the iLogic Add-in, when working within the iLogic Rule Editor dialog.  However, I could not find an online help area web page which documents this tool, or I would have provided a link to it here.  This tool appears to be somewhat of a 'behind the scenes' resource which appears to have most of the same functionality as the LanguageTools referred to by @CattabianiI.  It has the following members:

WCrihfield_0-1674488264763.png

Then there is the ModelStateUtils tool, which is also sourced from the 'Autodesk.iLogic.Runtime' reference, and also does not appear to have an online help webpage.  This is a really helpful and interesting tool, with several 'members', and you do not need to 'instantiate' it (no need to create a variable for it, or use 'New' to create one), which is also really nice.  Some of us may recognize some of these 'members' as having similar sounding normal API counterparts.  Again, this may be a 'behind the scenes' resource type tool.  Probably just for providing a 'shortcut' of sorts.  This tool has the following 'members':

WCrihfield_1-1674488553431.png

Then there is the ModelStateOperations tool, which is also from the Runtime source, and does not need to be instantiated, but only has two methods.  Not super useful, but nice to know its there.

WCrihfield_2-1674488993509.png

Then there are also a few ModelState related tools under the FileManager object (ThisApplication.FileManager), which there is actually a online help webpage for.

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)