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: 

Macro - Export renamed parameters in part document

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
316 Views, 3 Replies

Macro - Export renamed parameters in part document

Here's a macro that exports any parameters that have been renamed by the user in a part document. (Note that the macro checks for a 'd' character to determine if the parameter has been renamed. Is there a better way to do this?)

---------------------------------------------------------------------

Public Function GetActivePartDocument() As PartDocument

If ThisApplication.ActiveDocumentType = kPartDocumentObject Then
Set GetActivePartDocument = ThisApplication.ActiveDocument
End If

End Function


Public Function GetPartParameters(oPart As Inventor.PartDocument) As Inventor.Parameters
Set GetPartParameters = oPart.ComponentDefinition.Parameters
End Function



' Export all renamed parameters in a part document
Public Sub ExportRenamedParameters()

Dim oPartDoc As PartDocument
Set oPartDoc = GetActivePartDocument
If oPartDoc Is Nothing Then Exit Sub

Dim oParam As Parameter
For Each oParam In GetPartParameters(oPartDoc)

' if first character is not a "d" then assume parameter has been renamed
If StrComp(Left(oParam.Name, 1), "d") <> 0 Then
oParam.ExposedAsProperty = True
End If

Next oParam

End Sub
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

In Inventor 11 you need to use the name to determine if it has been renamed.
Your approach is correct except you should do an additional check. First,
make sure the first character is a "d" and then make sure the rest of the
name is all numeric values. (You can use the VB function IsNumeric.) This
way you won't assume names like "dia" are Inventor assigned names.
--
Brian Ekins
Autodesk Inventor API
Message 3 of 4
Anonymous
in reply to: Anonymous

>then make sure the rest of the name is all numeric values

ah, good idea! Thanks Brian
Message 4 of 4
trevorauman
in reply to: Anonymous

Did you ever finish this with the IsNumeric Function? It would save me a bit of time having to write it myself. I think I will add an additonal feature to set the values to inches from decimal, or I might see if I can do it in the .ipt template file. Ideas?

 

Just as a matter of information we are looking at creating an add in that woudl allow us to drop in standard parts that we use all of the time, such as gussets and plates with holes. In these tempaltes we would pre set the "description" in the iProperties to match the object. For example: =PLATE, <THK> THK x <WID> x <LNG> LNG so that we don't have to type that everytime. I'll let you all know how it goes.  

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

Post to forums  

Autodesk Design & Make Report