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

CAD tip CAD tip # 9340:

Question CAD 
 %  platform  category 
Q - question

Using iLogic to parse IPT filename and populate iProperties.

A - answer Assume that you have your IPT files named like PARTname-REVx.IPT (e.g. tracker9864-rev6-7-2013.ipt) and you want to automatically assign the part iProperties "Description" and "Revision" to the name and revision parsed from the file name.

You can use the following iLogic macro to do this. This macro uses regular expressions and their parenthesis groups to parse the filename and get the first and second part of the string delimited by "-" (in the first case) or parse the filename string by a fixed number of characters - 7 and 3 (in the second case, commented out):

docname=ThisDoc.FileName(False) 'e.g. "tracker9864-rev6-7-2013"

Dim matches As System.Text.RegularExpressions.MatchCollection
Dim match As System.Text.RegularExpressions.Match
Dim groups As System.Text.RegularExpressions.GroupCollection
matches = System.Text.RegularExpressions.Regex.Matches(docname, "\b([^-]+)-*([^-]+).*\b") '*****-****: $1/$2 = tracker9864/rev6
'matches = System.Text.RegularExpressions.Regex.Matches(docname, "\b(.{7})(.{3}).*\b") 'NNNNNNRRR*: $1/$2 = tracker/9864
If matches.count>0 Then
 For Each match In matches
  groups = match.Groups ' parenthesis 1 and 2
  iProperties.Value("Project", "Revision Number") = groups.item(2).Value
  iProperties.Value("Project", "Description") = groups.item(1).Value
  MsgBox("iProperties set to " & groups.item(1).Value & " and " & groups.item(2).Value)
 Next
 Else
 MsgBox("No match!")
End If

Similarly you can modify the BOM, drawing texts, etc. Change the regular expression as you need.

Inventor
100% *  CAD 
16.7.2013    2680x  
Comments   Tell a friend
applies to: Inventor ·

See also:
Tip 9952:iLogic rule - check whether iProperties are overridden.
Tip 9935:How to distinguish between an assembly and weldment in VBA or iLogic?
Tip 9812:How to switch a drawing sheet from portrait to landscape orientation?
Tip 9692:Unfoldable spiral-helix sheet metal in Inventor.
Tip 9659:iLogic: adjusting model parameters to match model volume or mass


Back   All CAD Tips All CAD tips&tricks

How to include hydrostatic pressure to my FEM simulations? « | » When moving one entity, the adjacent entity moves too.

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:
DwgTextTranslator translates a series of drawings from one language to another using MS Access.
Download a fully functional trial version.


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