Hi,
What code allow to create a macro button with :
In parameters :
- Check : Thickness
- Check : Trailing zeros (in "Custom property format")
Thanks,
Solved! Go to Solution.
Solved by mrattray. Go to Solution.
Try this:
Dim oDoc As Document Dim oSheetMetalCompDef As SheetMetalComponentDefinition Dim oParam As Parameter Dim oParamFormat As CustomPropertyFormat oDoc = ThisDoc.Document If oDoc.DocumentType <> kPartDocumentObject Then MsgBox("This rule is only valid for part documents.", vbOKOnly, "Error") Exit Sub End If Try oSheetMetalCompDef = oDoc.ComponentDefinition Catch Try oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" oSheetMetalCompDef = oDoc.ComponentDefinition Catch MsgBox("Part must be a sheet metal part. Please click the Convert Part to Sheet Metal button!",vbOKOnly,"Error") Exit Sub End Try End Try Try oParam = oSheetMetalCompDef.Parameters.ModelParameters.Item("Thickness") oParam.ExposedAsProperty = True oParamFormat = oParam.CustomPropertyFormat oParamFormat.ShowUnitsString = False oParamFormat.ShowLeadingZeros = False oParamFormat.ShowTrailingZeros = True oParamFormat.Precision = kThreeDecimalPlacesPrecision Catch MsgBox("Failure to format: Thickness", vbOKOnly, "Error") End Try
You can change the value of each true false statement to suite your needs. It should be self explanatory.
It's working with some modifications
oParam = oSheetMetalCompDef.Parameters.ModelParameters.Item("Epaisseur") oParam.ExposedAsProperty = True oParamFormat = oParam.CustomPropertyFormat oParamFormat.ShowUnitsString = False oParamFormat.ShowLeadingZeros = False oParamFormat.ShowTrailingZeros = True
I deleted the last msgbox because the box shows "Error", then there is no error !
Thank you !
Just for my information, what advantage to use iLogic rather than "VBA" ?
Sorry, I missed that you were using a different language than English. If you're getting the error message, than I would be concerned that one of the lines in the property formatting is not getting executed for some reason or another. Can you test and verify that it's actually changing each format option?
iLogic is a little easier to run directly from Inventor (in my opinion, anyways), but more significantly it offers some .NET functionality (like the Try Catch statements I used here) that is not available using traditional VBA in the API.
Hi amartin.r,
Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com