CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz]
Cesky English Deutsch
Login/Register:
 Visitors: 4042 

CAD tip CAD tip # 12432:

Question CAD 
 %  platform  category 
Q - question

Parse/replace Inventor iProperties using regular expressions.

A - answer With regular expressions in Autodesk Inventor's iLogic rules you can parse and replace part file names or derive, extract and fill individual iProperties of your Inventor documents.

The reg.exp. principles in the search portion is quite simple - the parentheses "()" capture the individual character groups, the braces "{}" define the number of characters. In the replacement portion then you can reference the captured groups with "$1", "$2" etc. (in the capture order). The code "\d" means a digit, the dot "." then any character and the plus "+" means any number of repetitions.

See examples:

' 770203010005.ipt --> Part number 77.02/03.01.00.05
' EP354-J12(C).ipt --> Part number J12-C/A354
docname = ThisDoc.FileName(False)
FN = System.Text.RegularExpressions.Regex.Replace(docname, "\b(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1.$2/$3.$4.$5.$6")
'FN = System.Text.RegularExpressions.Regex.Replace(docname, "\b(.{2})(\d+)\-(.)(\d+)\((.+)\)", "$3$4-$5/A$2")
iProperties.Value("Project", "Part Number") = FN
iLogicVb.UpdateWhenDone = True

iLogic - iProperty

See also the Tip 6967

Inventor
100% *  CAD 
1.12.2019    216×  
applies to: Inventor ·

See also:
Tip 9340:Using iLogic to parse IPT filename and populate iProperties.
Tip 8956:How to explode a component pattern in an Inventor assembly?


Back   All CAD Tips All CAD tips&tricks



Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   



Featuring:
Increase your productivity with our set of BIM add-on functions for Autodesk Revit
CADstudio Revit Tools More info


Please use these tips at your own risk.
CAD Studio is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist