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: 

Blocking editing iProperties

15 REPLIES 15
Reply
Message 1 of 16
kmcga
1010 Views, 15 Replies

Blocking editing iProperties

kmcga
Contributor
Contributor

Dear Experts,

 

I have a case where I need to block editing custom iProperties once "Stock Number" iProperty <> 0.

Ex.

If iProperty Stock Number <> 0

then lock/block editing custom iProperties Prop1, Prop2, Prop2.

 

How could I do that utilizing iLogic?

 

Best regards

 

Krzysztof

0 Likes

Blocking editing iProperties

Dear Experts,

 

I have a case where I need to block editing custom iProperties once "Stock Number" iProperty <> 0.

Ex.

If iProperty Stock Number <> 0

then lock/block editing custom iProperties Prop1, Prop2, Prop2.

 

How could I do that utilizing iLogic?

 

Best regards

 

Krzysztof

15 REPLIES 15
Message 2 of 16
WCrihfield
in reply to: kmcga

WCrihfield
Mentor
Mentor

Hi @kmcga.  What you are asking for, if possible, would be a very advanced and very complex to achieve using just iLogic.  That type of solution would be better suited for a custom Inventor add-in, instead of controlled by iLogic rules.  You would have to create custom event handler code(s) which would be launched/ran when that specific document opens, check/record the initial value of that Stock Number iProperty,  then it would need to stay running in the background while many possible other things are happening, and 'listen' for the specific event(s) of when someone attempts to change the values of any iProperties, then check if the property being changed is one of those specific few, then abort those commands before they can be finished.  Then this event listener code would need a way to terminate itself, once it is no longer needed, like when that specific document is closed.  

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

Hi @kmcga.  What you are asking for, if possible, would be a very advanced and very complex to achieve using just iLogic.  That type of solution would be better suited for a custom Inventor add-in, instead of controlled by iLogic rules.  You would have to create custom event handler code(s) which would be launched/ran when that specific document opens, check/record the initial value of that Stock Number iProperty,  then it would need to stay running in the background while many possible other things are happening, and 'listen' for the specific event(s) of when someone attempts to change the values of any iProperties, then check if the property being changed is one of those specific few, then abort those commands before they can be finished.  Then this event listener code would need a way to terminate itself, once it is no longer needed, like when that specific document is closed.  

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 16
kmcga
in reply to: WCrihfield

kmcga
Contributor
Contributor

Hi @WCrihfield,

 

thank you for your reply.

I'd like to avoid developing custom add-in since I haven't enough skills for that (lack of knowledge and skill for converting VBA code to add-in).

What do you think about VBA macro instead iLogic? I can't find any method which could be used for locking editing iProperties either.

 

Thank you in advance.

0 Likes

Hi @WCrihfield,

 

thank you for your reply.

I'd like to avoid developing custom add-in since I haven't enough skills for that (lack of knowledge and skill for converting VBA code to add-in).

What do you think about VBA macro instead iLogic? I can't find any method which could be used for locking editing iProperties either.

 

Thank you in advance.

Message 4 of 16
WCrihfield
in reply to: kmcga

WCrihfield
Mentor
Mentor

In my humble opinion, that would be an even worse option than using iLogic.  I have almost completely stopped using VBA in Inventor, due to the security risks, which is why Autodesk stopped including VBA Editor in Inventor.  Even though the VBA Editor has a more advanced user interface, and a really nice object browser dialog, compared to the simplistic iLogic rule editor, I still have always very much preferred using iLogic, when dealing with Inventor, because has a lot more potential than most folks realize.  Plus, the iLogic add-in's coding environment uses the newer vb.net coding system, allowing for more condensed code, and and easier error handling tools.  I am admittedly not an experienced Inventor Add-in creator, because even though I have Visual Studio installed, I do not have 'administrator's rights' on my work PC, due to corporate company wide restrictions.  But most folks use Visual Studio (from Microsoft) to write their Add-ins in either vb.net or C# coding language.  I have created several custom event handler codes before using iLogic alone, but I know that doing it that way is not nearly as ideal as a proper add-in that can be set to enabled when Inventor starts.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

In my humble opinion, that would be an even worse option than using iLogic.  I have almost completely stopped using VBA in Inventor, due to the security risks, which is why Autodesk stopped including VBA Editor in Inventor.  Even though the VBA Editor has a more advanced user interface, and a really nice object browser dialog, compared to the simplistic iLogic rule editor, I still have always very much preferred using iLogic, when dealing with Inventor, because has a lot more potential than most folks realize.  Plus, the iLogic add-in's coding environment uses the newer vb.net coding system, allowing for more condensed code, and and easier error handling tools.  I am admittedly not an experienced Inventor Add-in creator, because even though I have Visual Studio installed, I do not have 'administrator's rights' on my work PC, due to corporate company wide restrictions.  But most folks use Visual Studio (from Microsoft) to write their Add-ins in either vb.net or C# coding language.  I have created several custom event handler codes before using iLogic alone, but I know that doing it that way is not nearly as ideal as a proper add-in that can be set to enabled when Inventor starts.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 16
tyler.warner
in reply to: kmcga

tyler.warner
Advocate
Advocate

@kmcga You can try something like this rule. You will need to add this rule to the Property Changed Event Trigger. It will create a history property, and both a copy & history copy parameter since they trigger iLogic better. This will allow changes on the iProperties form but it will be reset & correct when you re-open it.

Sub Main
	
	Dim oDrawingDocument As DrawingDocument = ThisApplication.ActiveDocument
	Dim oParams As Parameters = oDrawingDocument.Parameters
	Dim oUserParams As UserParameters = oParams.UserParameters
	
    Dim oCustomPropertySet As PropertySet
    oCustomPropertySet = oDrawingDocument.PropertySets.Item("Inventor User Defined Properties") ' PropertiesForUserDefinedPropertiesEnum
	    
	CreateHistoryAndParametesForProp("Prop1", oUserParams, oCustomPropertySet)
	CreateHistoryAndParametesForProp("Prop2", oUserParams, oCustomPropertySet)
	CreateHistoryAndParametesForProp("Prop3", oUserParams, oCustomPropertySet)
		
	iLogicVb.UpdateWhenDone = True

End Sub

Function CreateHistoryAndParametesForProp(myPropertyName As String, oUserParams As UserParameters, oCustomPropertySet As PropertySet)
	
	Dim myProperty As Inventor.Property
	'Try
    	myProperty = oCustomPropertySet.Item(myPropertyName)
	'Catch
		'oCustomPropertySet.Add("", myPropertyName)
	'End Try
	
	Try
		oUserParams.Item("param" & myPropertyName).Value = iProperties.Value("Custom", myPropertyName)
	Catch
		oUserParams.AddByValue("param" & myPropertyName, iProperties.Value("Custom", myPropertyName), UnitsTypeEnum.kTextUnits)
	End Try	
	
	
	Dim myHistoryProperty As Inventor.Property
	Try
    	myHistoryProperty = oCustomPropertySet.Item(myPropertyName & "History")
	Catch
		oCustomPropertySet.Add(myProperty.Value, myPropertyName & "History")
	End Try
	
	Try
		oUserParams.Item("param" & myPropertyName & "History").Value = iProperties.Value("Custom", myPropertyName & "History")
	Catch
		oUserParams.AddByValue("param" & myPropertyName & "History", iProperties.Value("Custom", myPropertyName & "History"), UnitsTypeEnum.kTextUnits)
	End Try	
	
	
	If (iProperties.Value("Project", "Stock Number") <> "0") Then
		Try
			iProperties.Value("Custom", myPropertyName) = Parameter.Value("param" & myPropertyName & "History")
		Catch
			'MessageBox.Show("Didn't update " & myPropertyName)
		End Try
	Else
		Try
			iProperties.Value("Custom", myPropertyName & "History") = Parameter.Value("param" & myPropertyName)
		Catch
			'MessageBox.Show("Didn't update " & myPropertyName & "History")
		End Try
	End If	
	
End Function
If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
0 Likes

@kmcga You can try something like this rule. You will need to add this rule to the Property Changed Event Trigger. It will create a history property, and both a copy & history copy parameter since they trigger iLogic better. This will allow changes on the iProperties form but it will be reset & correct when you re-open it.

Sub Main
	
	Dim oDrawingDocument As DrawingDocument = ThisApplication.ActiveDocument
	Dim oParams As Parameters = oDrawingDocument.Parameters
	Dim oUserParams As UserParameters = oParams.UserParameters
	
    Dim oCustomPropertySet As PropertySet
    oCustomPropertySet = oDrawingDocument.PropertySets.Item("Inventor User Defined Properties") ' PropertiesForUserDefinedPropertiesEnum
	    
	CreateHistoryAndParametesForProp("Prop1", oUserParams, oCustomPropertySet)
	CreateHistoryAndParametesForProp("Prop2", oUserParams, oCustomPropertySet)
	CreateHistoryAndParametesForProp("Prop3", oUserParams, oCustomPropertySet)
		
	iLogicVb.UpdateWhenDone = True

End Sub

Function CreateHistoryAndParametesForProp(myPropertyName As String, oUserParams As UserParameters, oCustomPropertySet As PropertySet)
	
	Dim myProperty As Inventor.Property
	'Try
    	myProperty = oCustomPropertySet.Item(myPropertyName)
	'Catch
		'oCustomPropertySet.Add("", myPropertyName)
	'End Try
	
	Try
		oUserParams.Item("param" & myPropertyName).Value = iProperties.Value("Custom", myPropertyName)
	Catch
		oUserParams.AddByValue("param" & myPropertyName, iProperties.Value("Custom", myPropertyName), UnitsTypeEnum.kTextUnits)
	End Try	
	
	
	Dim myHistoryProperty As Inventor.Property
	Try
    	myHistoryProperty = oCustomPropertySet.Item(myPropertyName & "History")
	Catch
		oCustomPropertySet.Add(myProperty.Value, myPropertyName & "History")
	End Try
	
	Try
		oUserParams.Item("param" & myPropertyName & "History").Value = iProperties.Value("Custom", myPropertyName & "History")
	Catch
		oUserParams.AddByValue("param" & myPropertyName & "History", iProperties.Value("Custom", myPropertyName & "History"), UnitsTypeEnum.kTextUnits)
	End Try	
	
	
	If (iProperties.Value("Project", "Stock Number") <> "0") Then
		Try
			iProperties.Value("Custom", myPropertyName) = Parameter.Value("param" & myPropertyName & "History")
		Catch
			'MessageBox.Show("Didn't update " & myPropertyName)
		End Try
	Else
		Try
			iProperties.Value("Custom", myPropertyName & "History") = Parameter.Value("param" & myPropertyName)
		Catch
			'MessageBox.Show("Didn't update " & myPropertyName & "History")
		End Try
	End If	
	
End Function
If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
Message 6 of 16
WCrihfield
in reply to: kmcga

WCrihfield
Mentor
Mentor

As a starter, to help you towards your goal, here is a link to an article I wrote about creating/using custom 'event handler' codes with iLogic.  There are some ideas and terms involved that you will need to familiarize yourself with, and some processes, and precautions to know about when dealing with them.  It only shows one example code, for a completely different situations, but contains links to a whole lot of other similar 'Events' documentation, for some of the most common things that folks may want to 'listen' for, then react to by code. 

 

Pretty much every 'handler' routine that Autodesk offers documentation for includes a few common things that you will need to familiarize yourself with.  One of those common things included in those routines is something often labeled "BeforeOrAfter", which is a variable representing a variation of the EventTimingEnum.  You can check the value of this within the routine, and use that to separate different reaction code to the event, depending on the timing (before the command has completed its task, or after the command has finished).  Then there is also a variable usually labeled "HandlingCode", which represents a variation of the HandlingCodeEnum.  This can be used to set or change the status of the event/command, such as to cancel it before it completes (of handled in the 'Before' timing), or set it to 'Handled'.  When set to 'Handled', it will do your custom task, instead of the usual behavior of that event/command.  If set to 'not handled', it will continue to carry out its native task, as if you had not interrupted it.  

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

As a starter, to help you towards your goal, here is a link to an article I wrote about creating/using custom 'event handler' codes with iLogic.  There are some ideas and terms involved that you will need to familiarize yourself with, and some processes, and precautions to know about when dealing with them.  It only shows one example code, for a completely different situations, but contains links to a whole lot of other similar 'Events' documentation, for some of the most common things that folks may want to 'listen' for, then react to by code. 

 

Pretty much every 'handler' routine that Autodesk offers documentation for includes a few common things that you will need to familiarize yourself with.  One of those common things included in those routines is something often labeled "BeforeOrAfter", which is a variable representing a variation of the EventTimingEnum.  You can check the value of this within the routine, and use that to separate different reaction code to the event, depending on the timing (before the command has completed its task, or after the command has finished).  Then there is also a variable usually labeled "HandlingCode", which represents a variation of the HandlingCodeEnum.  This can be used to set or change the status of the event/command, such as to cancel it before it completes (of handled in the 'Before' timing), or set it to 'Handled'.  When set to 'Handled', it will do your custom task, instead of the usual behavior of that event/command.  If set to 'not handled', it will continue to carry out its native task, as if you had not interrupted it.  

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 16
tyler.warner
in reply to: kmcga

tyler.warner
Advocate
Advocate

@WCrihfield thanks for the resources, the event handling is a topic I'm working to improve my knowledge on!

If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
0 Likes

@WCrihfield thanks for the resources, the event handling is a topic I'm working to improve my knowledge on!

If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
Message 8 of 16
bradeneuropeArthur
in reply to: kmcga

bradeneuropeArthur
Mentor
Mentor

Long story short.
The part should be locked for edit when the property is 0, correct.

 

 

 

Dim a As Inventor.Application = ThisApplication
Dim b As Inventor.PartDocument = a.ActiveDocument
If b.PropertySets.Item(3).Item("Stock Number").Value = 0 Then
b.DisabledCommandTypes = Inventor.CommandTypesEnum.kFilePropertyEditCmdType
End If

 

bradeneuropeArthur_0-1675501347944.png

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Long story short.
The part should be locked for edit when the property is 0, correct.

 

 

 

Dim a As Inventor.Application = ThisApplication
Dim b As Inventor.PartDocument = a.ActiveDocument
If b.PropertySets.Item(3).Item("Stock Number").Value = 0 Then
b.DisabledCommandTypes = Inventor.CommandTypesEnum.kFilePropertyEditCmdType
End If

 

bradeneuropeArthur_0-1675501347944.png

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 9 of 16
kmcga
in reply to: bradeneuropeArthur

kmcga
Contributor
Contributor

Hi @bradeneuropeArthur,

 

it looks promising but I encountered an issue:

kmcga_0-1675685132083.png

 

Moreover, is there a method to block custom iProperties only?

 

Best regards

Krzysztof

0 Likes

Hi @bradeneuropeArthur,

 

it looks promising but I encountered an issue:

kmcga_0-1675685132083.png

 

Moreover, is there a method to block custom iProperties only?

 

Best regards

Krzysztof

Message 10 of 16
kmcga
in reply to: tyler.warner

kmcga
Contributor
Contributor

Hi @tyler.warner ,

 

I tried by replacing all "Drawing" phrases to "Part" and I encountered following error:

kmcga_1-1675685267667.png

 

I tried also to rework the rule a little bit but without success.

 

Best regards

Krzysztof

0 Likes

Hi @tyler.warner ,

 

I tried by replacing all "Drawing" phrases to "Part" and I encountered following error:

kmcga_1-1675685267667.png

 

I tried also to rework the rule a little bit but without success.

 

Best regards

Krzysztof

Message 11 of 16
WCrihfield
in reply to: kmcga

WCrihfield
Mentor
Mentor

Hi @kmcga.  Pertaining to your error while testing the code that @bradeneuropeArthur posted...try changing 0 to "0" (zero numerical value to a zero digit within quotation marks), because that specific iProperty's value Type is String, therefore it can not compare a numerical value to a String value.

 

And pertaining to the error you got after changing the code that @tyler.warner posted from working with a Drawing to a Part...when the document is either a Part or Assembly, the parameters are under the component definition (Document.ComponentDefinition.Parameters), while if the document is a Drawing, the parameters are right under the document (DrawingDocument.Parameters).  So, if you are wanting the code to work with a Part or Assembly, you will need to go another step deeper to get to the Parameters (include ComponentDefinition between Document & Parameters).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Hi @kmcga.  Pertaining to your error while testing the code that @bradeneuropeArthur posted...try changing 0 to "0" (zero numerical value to a zero digit within quotation marks), because that specific iProperty's value Type is String, therefore it can not compare a numerical value to a String value.

 

And pertaining to the error you got after changing the code that @tyler.warner posted from working with a Drawing to a Part...when the document is either a Part or Assembly, the parameters are under the component definition (Document.ComponentDefinition.Parameters), while if the document is a Drawing, the parameters are right under the document (DrawingDocument.Parameters).  So, if you are wanting the code to work with a Part or Assembly, you will need to go another step deeper to get to the Parameters (include ComponentDefinition between Document & Parameters).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 12 of 16
kmcga
in reply to: WCrihfield

kmcga
Contributor
Contributor

Hi, 

 

unfortunately, @bradeneuropeArthur's code doesn't work after correction - there is no error and no action.

Also, I haven't managed to rework @tyler.warner's code, the following error occurred.

kmcga_0-1675759377065.png

Reworked code:

Sub Main
	
	Dim oDocument As PartDocument = ThisApplication.ActiveDocument
	Dim oParams As Parameters = oDocument.ComponentDefinition.Parameters
	Dim oUserParams As UserParameters = oParams.UserParameters
	
    Dim oCustomPropertySet As PropertySet
    oCustomPropertySet = oDocument.PropertySets.Item("Inventor User Defined Properties") ' PropertiesForUserDefinedPropertiesEnum
	    
	CreateHistoryAndParametesForProp("Prop1", oUserParams, oCustomPropertySet)
	CreateHistoryAndParametesForProp("Prop2", oUserParams, oCustomPropertySet)
	CreateHistoryAndParametesForProp("Prop3", oUserParams, oCustomPropertySet)
		
	iLogicVb.UpdateWhenDone = True

End Sub

Function CreateHistoryAndParametesForProp(myPropertyName As String, oUserParams As UserParameters, oCustomPropertySet As PropertySet)
	
	Dim myProperty As Inventor.Property
	'Try
    	myProperty = oCustomPropertySet.Item(myPropertyName)
	'Catch
		'oCustomPropertySet.Add("", myPropertyName)
	'End Try
	
	Try
		oUserParams.Item("param" & myPropertyName).Value = iProperties.Value("Custom", myPropertyName)
	Catch
		oUserParams.AddByValue("param" & myPropertyName, iProperties.Value("Custom", myPropertyName), UnitsTypeEnum.kTextUnits)
	End Try	
	
	
	Dim myHistoryProperty As Inventor.Property
	Try
    	myHistoryProperty = oCustomPropertySet.Item(myPropertyName & "History")
	Catch
		oCustomPropertySet.Add(myProperty.Value, myPropertyName & "History")
	End Try
	
	Try
		oUserParams.Item("param" & myPropertyName & "History").Value = iProperties.Value("Custom", myPropertyName & "History")
	Catch
		oUserParams.AddByValue("param" & myPropertyName & "History", iProperties.Value("Custom", myPropertyName & "History"), UnitsTypeEnum.kTextUnits)
	End Try	
	
	
	If (iProperties.Value("Project", "Stock Number") <> "0") Then
		Try
			iProperties.Value("Custom", myPropertyName) = Parameter.Value("param" & myPropertyName & "History")
		Catch
			'MessageBox.Show("Didn't update " & myPropertyName)
		End Try
	Else
		Try
			iProperties.Value("Custom", myPropertyName & "History") = Parameter.Value("param" & myPropertyName)
		Catch
			'MessageBox.Show("Didn't update " & myPropertyName & "History")
		End Try
	End If	
	
End Function

 

Best regards

Krzysztof

 

0 Likes

Hi, 

 

unfortunately, @bradeneuropeArthur's code doesn't work after correction - there is no error and no action.

Also, I haven't managed to rework @tyler.warner's code, the following error occurred.

kmcga_0-1675759377065.png

Reworked code:

Sub Main
	
	Dim oDocument As PartDocument = ThisApplication.ActiveDocument
	Dim oParams As Parameters = oDocument.ComponentDefinition.Parameters
	Dim oUserParams As UserParameters = oParams.UserParameters
	
    Dim oCustomPropertySet As PropertySet
    oCustomPropertySet = oDocument.PropertySets.Item("Inventor User Defined Properties") ' PropertiesForUserDefinedPropertiesEnum
	    
	CreateHistoryAndParametesForProp("Prop1", oUserParams, oCustomPropertySet)
	CreateHistoryAndParametesForProp("Prop2", oUserParams, oCustomPropertySet)
	CreateHistoryAndParametesForProp("Prop3", oUserParams, oCustomPropertySet)
		
	iLogicVb.UpdateWhenDone = True

End Sub

Function CreateHistoryAndParametesForProp(myPropertyName As String, oUserParams As UserParameters, oCustomPropertySet As PropertySet)
	
	Dim myProperty As Inventor.Property
	'Try
    	myProperty = oCustomPropertySet.Item(myPropertyName)
	'Catch
		'oCustomPropertySet.Add("", myPropertyName)
	'End Try
	
	Try
		oUserParams.Item("param" & myPropertyName).Value = iProperties.Value("Custom", myPropertyName)
	Catch
		oUserParams.AddByValue("param" & myPropertyName, iProperties.Value("Custom", myPropertyName), UnitsTypeEnum.kTextUnits)
	End Try	
	
	
	Dim myHistoryProperty As Inventor.Property
	Try
    	myHistoryProperty = oCustomPropertySet.Item(myPropertyName & "History")
	Catch
		oCustomPropertySet.Add(myProperty.Value, myPropertyName & "History")
	End Try
	
	Try
		oUserParams.Item("param" & myPropertyName & "History").Value = iProperties.Value("Custom", myPropertyName & "History")
	Catch
		oUserParams.AddByValue("param" & myPropertyName & "History", iProperties.Value("Custom", myPropertyName & "History"), UnitsTypeEnum.kTextUnits)
	End Try	
	
	
	If (iProperties.Value("Project", "Stock Number") <> "0") Then
		Try
			iProperties.Value("Custom", myPropertyName) = Parameter.Value("param" & myPropertyName & "History")
		Catch
			'MessageBox.Show("Didn't update " & myPropertyName)
		End Try
	Else
		Try
			iProperties.Value("Custom", myPropertyName & "History") = Parameter.Value("param" & myPropertyName)
		Catch
			'MessageBox.Show("Didn't update " & myPropertyName & "History")
		End Try
	End If	
	
End Function

 

Best regards

Krzysztof

 

Message 13 of 16
tyler.warner
in reply to: kmcga

tyler.warner
Advocate
Advocate

Haha the solution I posted was ugly. The one from @bradeneuropeArthur works for parts, assemblies & drawings with the below code. But, how do you re-enable the command? It seems like even the iLogic commands are blocked from changing the iProperties after the command is disabled.

 

 

Dim oApplication As Inventor.Application = ThisApplication
Dim oDocument As Inventor.Document = oApplication.ActiveDocument

If oDocument.PropertySets.Item("Design Tracking Properties").Item("Stock Number").Value <> "0" Then
	oDocument.DisabledCommandTypes = Inventor.CommandTypesEnum.kFilePropertyEditCmdType
End If

 

 

If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.

Haha the solution I posted was ugly. The one from @bradeneuropeArthur works for parts, assemblies & drawings with the below code. But, how do you re-enable the command? It seems like even the iLogic commands are blocked from changing the iProperties after the command is disabled.

 

 

Dim oApplication As Inventor.Application = ThisApplication
Dim oDocument As Inventor.Document = oApplication.ActiveDocument

If oDocument.PropertySets.Item("Design Tracking Properties").Item("Stock Number").Value <> "0" Then
	oDocument.DisabledCommandTypes = Inventor.CommandTypesEnum.kFilePropertyEditCmdType
End If

 

 

If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
Message 14 of 16
kmcga
in reply to: tyler.warner

kmcga
Contributor
Contributor

I have just changed @bradeneuropeArthur's code and it works.

Dim a As Inventor.Application = ThisApplication
Dim b As Inventor.PartDocument = a.ActiveDocument
If (iProperties.Value("Project", "Stock Number") <> "0") Then
b.DisabledCommandTypes = Inventor.CommandTypesEnum.kFilePropertyEditCmdType
End If

 

Still, I wonder whether there is an option to block only custom iProperties instead of all.

Is it possible at all?

 

 

0 Likes

I have just changed @bradeneuropeArthur's code and it works.

Dim a As Inventor.Application = ThisApplication
Dim b As Inventor.PartDocument = a.ActiveDocument
If (iProperties.Value("Project", "Stock Number") <> "0") Then
b.DisabledCommandTypes = Inventor.CommandTypesEnum.kFilePropertyEditCmdType
End If

 

Still, I wonder whether there is an option to block only custom iProperties instead of all.

Is it possible at all?

 

 

Message 15 of 16
WCrihfield
in reply to: kmcga

WCrihfield
Mentor
Mentor

As I mentioned in 'Message 6' of this topic, I believe it is possible, just really complicated to code a solution like that.  It's not going to be a simple little iLogic rule, like any of these above, if you want it to be super specific.  It would need to be either a custom add-in, or a combination of one or more complex iLogic rule(s), together with proper use of the Event Triggers dialog, to help initially launch it.  You would need some custom code running in the background, that will automatically check the value of that Stock Number property, and will be silently listening for specific events to happen, then after confirming certain checks, will cancel or abort any attempts to change those specific property values, if/when they happen.  But I do not currently have a ready-made solution, customized to your specific needs to post right now.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

As I mentioned in 'Message 6' of this topic, I believe it is possible, just really complicated to code a solution like that.  It's not going to be a simple little iLogic rule, like any of these above, if you want it to be super specific.  It would need to be either a custom add-in, or a combination of one or more complex iLogic rule(s), together with proper use of the Event Triggers dialog, to help initially launch it.  You would need some custom code running in the background, that will automatically check the value of that Stock Number property, and will be silently listening for specific events to happen, then after confirming certain checks, will cancel or abort any attempts to change those specific property values, if/when they happen.  But I do not currently have a ready-made solution, customized to your specific needs to post right now.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 16 of 16

bradeneuropeArthur
Mentor
Mentor

As @WCrihfield mentioned these pieces of codes are the beginning.

The best option is to create an addin for it. Because you will need specific events to be triggered.

Let us know if this is what you need!

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

0 Likes

As @WCrihfield mentioned these pieces of codes are the beginning.

The best option is to create an addin for it. Because you will need specific events to be triggered.

Let us know if this is what you need!

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

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

Post to forums  

Autodesk Design & Make Report