What are your go-to iLogic external rules and snippets that you care to share?

What are your go-to iLogic external rules and snippets that you care to share?

claudio.ibarra
Advocate Advocate
1,387 Views
7 Replies
Message 1 of 8

What are your go-to iLogic external rules and snippets that you care to share?

claudio.ibarra
Advocate
Advocate

Which iLogic rules or custom snippets do you feel you can't go back to not having? 

0 Likes
1,388 Views
7 Replies
Replies (7)
Message 2 of 8

arsenii_yavtushenko
Contributor
Contributor

Hello,

 

What about the Scale rule for older Inventor? Basically it just adds first view's scale to the User Parameters, so it could then be used in a title block.

Again, newer Inventor versions already have it embedded, but it is not a thing in an Inventor 2014 or older.

Dim odrawdoc As DrawingDocument
odrawdoc = ThisApplication.ActiveDocument
customPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties")
For i = 1 To odrawdoc.Sheets.Count
' Make sure the desired property exists
Try
      prop = customPropertySet.Item("Scale" + Str(i))
Catch
      ' Assume error means not found
      customPropertySet.Add("", "Scale" + Str(i))
End Try
Try
iProperties.Value("Custom", "Scale" + Str(i)) = odrawdoc.sheets.item(i).DrawingViews.Item(1).ScaleString
Catch
End Try
Next i
InventorVb.DocumentUpdate()

Hope this helps and best of luck!

0 Likes
Message 3 of 8

mjordan3
Advocate
Advocate

A lot of mine are from work, so I can't really share them, but most of the good ones I've found are from this forum and blogs such as:

Manufacturing DevBlog, and

Mod the Machine 

0 Likes
Message 4 of 8

claudio.ibarra
Advocate
Advocate

Could you share the gist of what some of them accomplish, like "they let me do [something] to drawing notes" or "they bundle up [x] information in assemblies to [y]" ?

0 Likes
Message 5 of 8

mjordan3
Advocate
Advocate

These are some of ours:

 

  • We have the concept of inventor component types (e.g. Inventoried, Fabricated, managed-rental-asset, purchased non-inventoried, standard parts, etc) that control how the iproperties map, parts lists are formatted, and some other stuff.  We have a series of scripts that change the type for current or selected components, as well as manage and manipulate these
  • A script that exports the parts lists to a bom template that serves as our purchasing list, picking sheet, fabrication work orders, general bom (uses the types to determine where the part is coming from. etc)
  • edit scales of all drawing views on a sheet at one time
  • batch place drawing views of single parts for cnc router and wj pages
  • create standard drawing (part-per-page) files from a component model, saves to appropriate location w/ appropriate name
  • scripts to manipulate iproperties in safe ways (don't error out when they are missing or case is wrong)
  • same with parameters
  • regex library functions for use in our scripts (ReturnRegex, TestRegex, ReturnNotRegex)
  • scripts to push the properties from a drawing set back into the parts (such as job number/name, etc)
  • assign raw materials to parts for use in our purchasing system (automatically pulls the materials from an excel table that acts as our parts database since oracle fusion is horrendous)
  • Revision table tools that let you batch edit, reset, increment revisions
  • multibody renaming tool
  • add dimension overrides/annotations (such as OC, TYP, etc)
  • get iproperty data (project name, number, task, etc) from the directory structure
  • ground everything
  • explode component patterns
  • export cnc pages for the waterjet/router
  • change address in titleblocks between our various facilities
  • batch component operations (migrate to latest version, manipulate types, etc)
  • manipulate bom structure
  • function to get the document from the most commonly selected drawing/model/code objects
  • change component uom

 

0 Likes
Message 6 of 8

mjordan3
Advocate
Advocate

Here is one that was done at home...

 

'###########################
'###   Change to Front   ###
'###########################
' v1.0
'
'MDJ
'Set the Front view to match whatever is selected!  This routine is intended
'to make it easier to set a front view for cnc parts.  It will also set the
'left iso (from front) as home.
'There are two modes: ' 1. If a face or edge is selected, the Front view is set normal to that selection, ' 2. If nothing is selected, the current view is set as front. 'based on https://forums.autodesk.com/t5/inventor-customization/setting-view-cube-orientation-with-ilogic/m-p/8187506' Sub Main() Dim oApp As Application = ThisApplication Dim oDoc As Document = ThisDoc.Document Select Case oDoc.DocumentType Case kDrawingDocumentObject, kDesignElementDocumentObject, kNoDocument, kUnknownDocumentObject MsgBox ("This tool is not compatible with this type of file.") Case kForeignModelDocumentObject, kPresentationDocumentObject, kSATFileDocumentObject, kAssemblyDocumentObject, kPartDocumentObject ChangeFrontWrapper(oApp) Exit Sub End Select End Sub Public Sub ChangeFrontWrapper(ByRef oApp As Application) Dim oDoc As Document = ThisDoc.Document Dim oldSelectionPriority = oDoc.SelectionPriority oDoc.SelectionPriority = 67587 ChangeFront(oApp) ChangeHome(oApp) oDoc.SelectionPriority = oldSelectionPriority oApp.ActiveDocument.Save End Sub Sub ChangeFront(ByRef oApp As Application) Dim oDoc As Document = ThisDoc.Document Dim oSSet As SelectSet = oApp.ActiveDocument.SelectSet 'get the current selection set Dim tempCollection As Collection ' See if anything is selcted If oSSet.count = 0 Then 'if nothing is selected, make the current view FRONT oApp.CommandManager.ControlDefinitions("AppViewCubeViewFrontCmd").Execute Else if oSSet.count = 1 Then 'if there are selected objects, get the documents from them and run your code Dim LookAt As ControlDefinition = oApp.CommandManager.ControlDefinitions("AppLookAtCmd") LookAt.Execute() oSSet.Clear() Dim activeView As View = oApp.ActiveView activeView.SetCurrentAsFront() oApp.ActiveDocument.Save Else msgBox("Too many objects selected! Exiting now.") End If 'oSSet.count End Sub Public Sub ChangeHome(ByRef oApp As Application) 'set to iso view Dim oCamera As Camera oCamera = oApp.ActiveView.Camera oCamera.ViewOrientationType = 10760 'Iso Top Left View Orientation oCamera.Apply 'set current iso as home view oApp.CommandManager.ControlDefinitions("AppViewCubeViewHomeFloatingCmd").Execute 'return to front oCamera.ViewOrientationType = 10764 'Front View Orientation oCamera.Apply End Sub
Message 7 of 8

JelteDeJong
Mentor
Mentor

I dont like the interface for writing iLogic rule. There for i created a visual studio solution for writing iLogic rules. Rules created in that solution can be copyed/pasted to an iLogic rule. However I did not manage to get all functionality from iLogic in there but im planning to expand. But i have als some functions that are not standard in iLogic that can be very usfull. For eaxample a function that will tell you the type of an object. (Some times its not clear what type of object a function returns)

Also in the same project i have an event logger. Also here only a few events are logged but i plan to expand them.

 

for anyone who is interested. the visual studio solution can be found on github. (Also the source code of 2 addin that i created can be found there.)

Jelte de Jong
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


Blog: hjalte.nl - github.com

Message 8 of 8

mjordan3
Advocate
Advocate

Agreed, since I've started using VS for other stuff, I have a hard time in the ilogic editor. I'm bookmarking your repo to look through it later.

I'd just posted an ilogic code compiler for use in visual studio the other day, you might find it useful...  ilogic-quot-build-quot-tool-for-ide-users