Recording keyboard sequences

Recording keyboard sequences

mjohnson
Contributor Contributor
2,600 Views
42 Replies
Message 1 of 43

Recording keyboard sequences

mjohnson
Contributor
Contributor

Is it possible to record keyboard sequences to shorten a repeated series of mouse clicks and keyboard entries that I find I am doing over and over throughout the work day?  I was able to do this with Creo software and was hoping it is available for Inventor.

0 Likes
Accepted solutions (3)
2,601 Views
42 Replies
Replies (42)
Message 2 of 43

swalton
Mentor
Mentor
I am not aware of anything similar to Creo Mapkeys.

You might be able to write some iLogic rules to automate your tasks, but that requires understanding the iLogic scripting language. I don't find it as easy as recording macros with Mapkeys.

Steve Walton
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Inventor 2025
Vault Professional 2025
Message 3 of 43

alewer
Advocate
Advocate

Inventor does not generally have a straightforward way to record and replay inputs like mouse clicks and keystrokes. There are however generic (not specifically for Inventor) tools like AutoHotkey that might help. What Inventor does have is a powerful API that can automate almost everything that you can do with the GUI... but with a with a different (and more powerful) approach than simply automating a user's mouse+keyboard inputs. You can use the API with VBA macros, iLogic, .NET add-ins, and .NET standalone applications. Can you provide an example of the sort of task that you are trying to automate?

 

Resources:

AutoHotkey 

Inventor API User's Manual 

Inventor iLogic API VBA forum 

Message 4 of 43

mjohnson
Contributor
Contributor

Thankyou for the feedback.

For each part file I link the sketch parameters for the overall size(x and y dimension) to the iproperties custom dialog box.  This way the drawing part description, which includes the overall size of the part, in the drawing and in the assembly drawing BOM description shows up accurately.  Previously we were manually typing these dimensions into the description but every time the part size changed we would need to remember to change the description to match.

I would like to automate the process of creating and exporting the parameters to the part description. 

Where I worked before we used Creo and there was a tool called Mapkeys that would have worked great for this application. 

 

 I will check out the Inventor API User's Manual you linked to below and learn how to automate the Inventor way however I'm not very familiar with VBA macros.   Thanks for the feedback!

0 Likes
Message 5 of 43

swalton
Mentor
Mentor

Are you leveraging iProperty Expressions? 

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2016...

 

Have you considered creating specfic part template files to build common shapes with all the iProp and Parameter modifications already completed?

Steve Walton
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Inventor 2025
Vault Professional 2025
Message 6 of 43

mjohnson
Contributor
Contributor

Unfortunately most of our parts are created from existing parts using "copy design" so we don't normally start from scratch with a part template. 

The iProperty expressions link you sent may be helpful though. 

0 Likes
Message 7 of 43

swalton
Mentor
Mentor

I am seeing some issues with Vault Copy Design and iProperty expressions.  I suspect that I have something miss-configured because Copy Design is wiping out the expression and replacing it with the text from the parent.

 

I have a post over in the Vault forum trying to see what I need to change to fix the issue.

Steve Walton
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Inventor 2025
Vault Professional 2025
Message 8 of 43

mjohnson
Contributor
Contributor

Thanks, I will keep that in mind going forward.  I appreciate your input. 

0 Likes
Message 9 of 43

A.Acheson
Mentor
Mentor

@mjohnson wrote:

Unfortunately most of our parts are created from existing parts using "copy design" so we don't normally start from scratch with a part template. 

The iProperty expressions link you sent may be helpful though. 


Can you supply a quick screenshot or even list of the parameters to iproperties you usually transcribe? If they are the same for each document it should be an easy rule to make. You would use an external rule(independent/external to files) which would look to the document grab the document parameter value and then inject it into the iproperty you want. The sample you provide can be used to help target a rule to suit your task. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 10 of 43

mjohnson
Contributor
Contributor

Below shows shows the steps I would take to create the part description.  d0 is always the longest dimension and d1 always the shortest.  In the parameters dialog box I select "d0", "d1" and "THICKNESS" for export.  Then I go into the iProperties, Custom tab and copy the formula "=<THICKNESS> X <d1> X <d0> LG." into the "size" entry.  I have to do this for every part the appears on a drawing for the description to be correct.  

 

 

mjohnson_3-1638393912311.png

mjohnson_4-1638393966023.png

 

mjohnson_5-1638394017376.png

 

 

 

 

 

 

 

0 Likes
Message 11 of 43

A.Acheson
Mentor
Mentor

Thanks for supplying the screen shots and descriptions that really helps to find the correct information. 

If you are not familiar with working with external rules here are two links to get you started. 

https://autodeskmfg.typepad.com/blog/2012/01/working-with-external-ilogic-rules.html

https://forums.autodesk.com/t5/inventor-forum/add-create-external-rule-ilogic/td-p/6033312

 

Paste the rule below into the external rule editor and then run on your part document.

'http://inventortrenches.blogspot.com/2013/10/ilogic-how-to-learn-inventors.html
'https://forums.autodesk.com/t5/inventor-forum/add-create-external-rule-ilogic/td-p/6033312
'https://forums.autodesk.com/t5/inventor-forum/ilogic-that-tells-the-difference-between-parts-and-assemblies/td-p/6211252

DocType = ThisApplication.ActiveDocument.DocumentType

If DocType  = DocumentTypeEnum.kAssemblyDocumentObject Then
	MessageBox.Show("it's an assembly file - Exiting!", "iLogic")
 
Else If DocType = DocumentTypeEnum.kPartDocumentObject Then
	'MessageBox.Show("it's a part file", "iLogic")
    

'Get the document we want to work with
Dim partDoc As PartDocument
partDoc = ThisApplication.ActiveDocument

Try
'https://modthemachine.typepad.com/my_weblog/2010/04/parameters-as-iproperties.html
'Export parameters as custom iproperty (Tick the box)
Dim param As Parameter
param = partDoc.ComponentDefinition.Parameters.Item("d0")
param.ExposedAsProperty = True
param = partDoc.ComponentDefinition.Parameters.Item("d1")
param.ExposedAsProperty = True
param = partDoc.ComponentDefinition.Parameters.Item("Thickness")
param.ExposedAsProperty = True
Catch
MessageBox.Show("One of the parameters is missing", "iLogic")
End Try

' Get the User Defined property set.
Dim UserDefinedPropSet As PropertySet
UserDefinedPropSet  = partDoc.PropertySets.Item("Inventor User Defined Properties")

' Get the Size property.
Dim SizeProp As Property
SizeProp = UserDefinedPropSet.Item("Size")
Try
' Add an expression to the custom property.
SizeProp.Expression = _
                     "=<Thickness> X <d1> X <d0> LG."
Catch
MessageBox.Show("One of the parameters is missing", "iLogic")
End Try

Else If DocType = DocumentTypeEnum.kDrawingDocumentObject Then
	MessageBox.Show("it's a drawing file - Exiting!", "iLogic")
End If

The rule above contains API expressions that have been found from helpful topics online which are laid out in a user friendly way specific to the topics. This information is also available in the API help although the contents may not be as digestible. This link shows how to find this information, 

http://inventortrenches.blogspot.com/2013/10/ilogic-how-to-learn-inventors.html

 

Here is some deeper learning to show the capabilities

https://knowledge.autodesk.com/support/inventor/learn-explore/caas/CloudHelp/cloudhelp/2022/ENU/Inve...

 

https://www.autodesk.com/autodesk-university/class/Inventor-iLogic-Beyond-Basics-2017#video

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 12 of 43

cadman777
Advisor
Advisor

Here's a thread that may help you figure something out.

I have no experience in it, so just giving you a heads-up for further investigation.

Also you can look up app in the Autodesk Inventor App Store.

Maybe there's something there that can help without having to dive into the morass of coding.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 13 of 43

mjohnson
Contributor
Contributor

Awesome! thankyou.

It seems to be getting hung up on line 37.  See yellow highlight below.

 

 

mjohnson_0-1638450660586.png

 

0 Likes
Message 14 of 43

mjohnson
Contributor
Contributor
Thank you, I will check it out.
0 Likes
Message 15 of 43

A.Acheson
Mentor
Mentor

Use Inventor.Property instead of Property

when declaring the property. 

This is a common issue in changing VBA code back to Vb.Net code. I am not sure why it needs this but is one of differences. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 16 of 43

mjohnson
Contributor
Contributor

It worked! thank you for your help.

 

One more minor issue.  I still have to go into parameters - custom Property Format - and change the format from decimal to fraction as shown below otherwise the drawing description shows these dimension in decimal format.  Looks like the default is set to decimal.

I had to do this before also but forgot to mention it earlier.

 

mjohnson_1-1638469043808.png

 

 

0 Likes
Message 17 of 43

A.Acheson
Mentor
Mentor

No problem. I left out that formatting so if you look to this article you will see the snippets of code needed to change that formatting. Insert what you need, likely just the precision line needed. 

https://modthemachine.typepad.com/my_weblog/2010/04/parameters-as-iproperties.html


And this post here is specific to changing precision to fraction.

 

“param.CustomPropertyFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision“

You can set this rule to run on all parts in an assembly if you want (extra speed) a little more work but more time with your feet up later. Here is the link.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 18 of 43

mjohnson
Contributor
Contributor

Thank you for sending the links.

I was not able to get any of these to work in my case.  I don't know enough about coding to figure out what is wrong.

I just need "Thickness", "d0" and "d1" to change from decimal to Fractional, and precision to be 1/16".

Is there a code I could insert into the snippet you already sent me?

 

I appreciate all of your help.

 

mjohnson_0-1638474963879.png

mjohnson_1-1638475004038.png

 

 

0 Likes
Message 19 of 43

A.Acheson
Mentor
Mentor

 

Please make sure you copy the same settings under each parameter value. I have corrected the rule below. See if that works. If it does not please post the rule you are running and hopefully we can find the issue. 

 

'http://inventortrenches.blogspot.com/2013/10/ilogic-how-to-learn-inventors.html
'https://forums.autodesk.com/t5/inventor-forum/add-create-external-rule-ilogic/td-p/6033312
'https://forums.autodesk.com/t5/inventor-forum/ilogic-that-tells-the-difference-between-parts-and-assemblies/td-p/6211252

DocType = ThisApplication.ActiveDocument.DocumentType

If DocType  = DocumentTypeEnum.kAssemblyDocumentObject Then
	MessageBox.Show("it's an assembly file - Exiting!", "iLogic")
 
Else If DocType = DocumentTypeEnum.kPartDocumentObject Then
	'MessageBox.Show("it's a part file", "iLogic")
    

'Get the document we want to work with
Dim partDoc As PartDocument
partDoc = ThisApplication.ActiveDocument

Try
'https://modthemachine.typepad.com/my_weblog/2010/04/parameters-as-iproperties.html
'Export parameters as custom iproperty (Tick the box)
Dim param As Parameter
'[d0
param = partDoc.ComponentDefinition.Parameters.Item("d0") param.ExposedAsProperty = True oFormat=param.CustomPropertyFormat

oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Units="in"
 oFormat.ShowUnitsString = True

oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision

'oFormat.ShowTrailingZeros = False

'oFormat.ShowLeadingZeros = False ']
'[ d1 param = partDoc.ComponentDefinition.Parameters.Item("d1") param.ExposedAsProperty = True oFormat=param.CustomPropertyFormat
oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Units="in"
 oFormat.ShowUnitsString = True

oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision

'oFormat.ShowTrailingZeros = False
'oFormat.ShowLeadingZeros = False ']
'[Thickness param = partDoc.ComponentDefinition.Parameters.Item("Thickness") param.ExposedAsProperty = True oFormat=param.CustomPropertyFormat
oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Units="in"
 oFormat.ShowUnitsString = True

oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision

'oFormat.ShowTrailingZeros = False

'oFormat.ShowLeadingZeros = False '] Catch MessageBox.Show("One of the parameters is missing", "iLogic") End Try ' Get the User Defined property set. Dim UserDefinedPropSet As PropertySet UserDefinedPropSet = partDoc.PropertySets.Item("Inventor User Defined Properties") ' Get the Size property. Dim SizeProp As Inventor.Property SizeProp = UserDefinedPropSet.Item("Size") Try ' Add an expression to the custom property. SizeProp.Expression = _ "=<Thickness> X <d1> X <d0> LG." Catch MessageBox.Show("One of the parameters is missing", "iLogic") End Try Else If DocType = DocumentTypeEnum.kDrawingDocumentObject Then MessageBox.Show("it's a drawing file - Exiting!", "iLogic") End If

 Here is a post that goes through these settings. Just in case they were not set correctly 
https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/change-format-of-exported-parameter-to-...

 

Edit: Corrected formatting errors above.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 20 of 43

A.Acheson
Mentor
Mentor
Accepted solution

After testing the previous rule, I noticed that if the "size" iProperty is missing and the rule will error out. Here is the corrected version which adds the iProperty before attempting to assign the expression. 

'http://inventortrenches.blogspot.com/2013/10/ilogic-how-to-learn-inventors.html
'https://forums.autodesk.com/t5/inventor-forum/add-create-external-rule-ilogic/td-p/6033312
'https://forums.autodesk.com/t5/inventor-forum/ilogic-that-tells-the-difference-between-parts-and-assemblies/td-p/6211252

DocType = ThisApplication.ActiveDocument.DocumentType

If DocType  = DocumentTypeEnum.kAssemblyDocumentObject Then
	MessageBox.Show("it's an assembly file - Exiting!", "iLogic")
 
ElseIf DocType = DocumentTypeEnum.kPartDocumentObject Then
		'MessageBox.Show("it's a part file", "iLogic")
	    

	'Get the document we want to work with
	Dim partDoc As PartDocument
	partDoc = ThisApplication.ActiveDocument

	Try
	'https://modthemachine.typepad.com/my_weblog/2010/04/parameters-as-iproperties.html
	'Export parameters as custom iproperty (Tick the box)
	Dim param As Inventor.Parameter
	Dim oFormat As CustomPropertyFormat
	'[d0
	param = partDoc.ComponentDefinition.Parameters.Item("d0")
	param.ExposedAsProperty = True

	oFormat = param.CustomPropertyFormat
	oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType
	oFormat.Units = "in"
	oFormat.ShowUnitsString = True
	oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision'oFormat.ShowTrailingZeros = False
	'oFormat.ShowLeadingZeros = False
	']
	'[d1
	param = partDoc.ComponentDefinition.Parameters.Item("d1")
	param.ExposedAsProperty = True
	oFormat = param.CustomPropertyFormat
	oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType
	oFormat.Units = "in"
	oFormat.ShowUnitsString = True
	oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision
	']

	'[Thickness
	param = partDoc.ComponentDefinition.Parameters.Item("Thickness")
	param.ExposedAsProperty = True
	oFormat = param.CustomPropertyFormat
	oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType
	oFormat.Units = "in"
	oFormat.ShowUnitsString = True
	oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision
	']
	Catch
	MessageBox.Show("One of the parameters is missing", "iLogic")
	End Try

	' Get the User Defined property set.
	Dim UserDefinedPropSet As PropertySet
	UserDefinedPropSet = partDoc.PropertySets.Item("Inventor User Defined Properties")

	' Get the Size property.
	Dim SizeProp As Inventor.Property
	Try
	SizeProp = UserDefinedPropSet.Item("Size")
	Catch
	' Failed to get the property, which means it doesn't exist so we'll create it.
	UserDefinedPropSet.Add("", "Size")
	SizeProp = UserDefinedPropSet.Item("Size")
	End Try

	'Add an expression to custom property
	SizeProp.Expression = _
	                     "=<Thickness> X <d1> X <d0> LG."
	
	MessageBox.Show("Size: " & SizeProp.Value, "iLogic- Success iProp Updated")

ElseIf DocType = DocumentTypeEnum.kDrawingDocumentObject Then
	MessageBox.Show("it's a drawing file - Exiting!", "iLogic")
End If

 

And here is another version using VB.Net method instead of a pure iLogic rule. I have just place the parameter export into a sub routine as they have all the same formatting it makes the rule a little easier to read.

Sub Main
DocType = ThisApplication.ActiveDocument.DocumentType

If DocType  = DocumentTypeEnum.kAssemblyDocumentObject Then
	MessageBox.Show("it's an assembly file - Exiting!", "iLogic")
 
ElseIf DocType = DocumentTypeEnum.kPartDocumentObject Then
'Get the document we want to work with Dim partDoc As PartDocument partDoc = ThisApplication.ActiveDocument Try 'Pass document and parameter to sub routine ParameterExport(partDoc, "d0") ParameterExport(partDoc, "d1") ParameterExport(partDoc, "Thickness") Catch MessageBox.Show("One of the parameters is missing", "iLogic") End Try ' Get the User Defined property set. Dim UserDefinedPropSet As PropertySet UserDefinedPropSet = partDoc.PropertySets.Item("Inventor User Defined Properties") ' Get the Size property. Dim SizeProp As Inventor.Property Try SizeProp = UserDefinedPropSet.Item("Size") Catch ' Failed to get the property, which means it doesn't exist so we'll create it. UserDefinedPropSet.Add("", "Size") SizeProp = UserDefinedPropSet.Item("Size") End Try 'Add an expression to custom property SizeProp.Expression = _ "=<Thickness> X <d1> X <d0> LG." MessageBox.Show("Size: " & SizeProp.Value, "iLogic- Success iProp Updated") ElseIf DocType = DocumentTypeEnum.kDrawingDocumentObject Then MessageBox.Show("it's a drawing file - Exiting!", "iLogic") End If End Sub Sub ParameterExport(oPartDoc As Document, oParam As String) 'Export parameters as custom iproperty (Tick the box) Dim param As Inventor.Parameter Dim oFormat As CustomPropertyFormat param = oPartDoc.ComponentDefinition.Parameters.Item(oParam) param.ExposedAsProperty = True 'Carry out formatting oFormat = param.CustomPropertyFormat oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Units = "in" oFormat.ShowUnitsString = True oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes