ConMan Posted December 6, 2013 Share Posted December 6, 2013 We use a center of gravity work point generator where I work. The readme is by Bob Van der Donck w/ Autodesk and the files are "UpdateCOG.bas" and "DocEventsClass.cls". I think this add-in has been posted elsewhere in the forum. It no longer appears to be running in Inventor 2014. I opened our assembly template in Default mode and ran the VBA editor. The two files listed above appear correctly (AFAIK) in the Document Project tree. I know that AutoCAD Mechanical 2014 has a new security feature that disallows lisp routines. We had to copy our company's lisp routines onto each computer's C drive in the trusted Autodesk folder so they would be seen as trustworthy. Is this issue with Inventor perhaps related? Does anyone know of a way to make the center of gravity add-in work? Do I need to re-locate the listed files and reload them into VBA from a trusted folder? I can project the built-in Inventor center of gravity in drawings which is better than nothing but we really need the functionality of the add-in for what we do here. Any tips would be much appreciated! Quote Link to comment Share on other sites More sharing options...
ConMan Posted December 9, 2013 Author Share Posted December 9, 2013 So just found the following on Mod the Machine blog: Autodesk Inventor 2014 removes support for VBA auto-run macros that are embedded in Autodesk Inventor documents. The VBA macros are AutoOpen, AutoNew, AutoSave, AutoClose, and AutoEdit. They can severely impact Autodesk Inventor performance, and pose a possible security risk. The suggested alternative to auto macros is an add-in. Add-ins don't have the performance and security issues of auto macros and provide much better source control. It has been a long time since my one term of Visual Basic in college, anyone have any info as to how to resolve this? Quote Link to comment Share on other sites More sharing options...
evilberger Posted December 11, 2013 Share Posted December 11, 2013 Here is the ilogic way...I work with conman ' Set a reference to the active document. Dim oDoc As AssemblyDocument oDoc = ThisApplication.ActiveDocument ' Get the Center of Mass. Dim oCenterOfMass As Point oCenterOfMass = oDoc.ComponentDefinition.MassProperties.CenterOfMass ' Check to see if a work point for center of mass already exists. ' This uses the name of the work feature to identify it. On Error Resume Next Dim oWorkPoint As WorkPoint oWorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("Center Of Mass") If Err.Number = 0 Then Dim oFixedDef As AssemblyWorkPointDef oFixedDef = oWorkPoint.Definition oFixedDef.Point = oCenterOfMass oDoc.Update Else ' Create a new workpoint at the location of the center of mass. oWorkPoint = oDoc.ComponentDefinition.WorkPoints.AddFixed(oCenterOfMass) ' Rename the work point. oWorkPoint.Name = "Center Of Mass" End If Quote Link to comment Share on other sites More sharing options...
ConMan Posted December 11, 2013 Author Share Posted December 11, 2013 So to wrap this item up and create a mini iLogic tutorial, here's how we resolved this issue: In assembly template file, went to Tools\VBA Editor and deleted old macro files (in our case it's the "UpdateCOG" and "DocEventsClass" listed above). This may not have been necessary since Inventor 2014 isn't running macros anymore but it seemed like a good idea. Then went to Manage\iLogic and clicked "Add rule" (named "CoG" in our case). This popped up a window where we pasted in the text code from above. When we clicked OK on this window an error popped up ("exception from HRESULT: 0x90004005 (E_FAIL)"). This is because Inventor is trying to run the code, but there is nothing to calculate mass on (in our case anyway, our assembly template is devoid of parts). Clicked OK/Cancel as required to make pop-up go away. Next clicked on Event Triggers and highlighted "After Save Document" then clicked "Select Rules" button. Clicked in check box to toggle on code for that event. Also added to "Component Suppression Change" event. Saved changes and that was that. A third coworker of ours with stronger Google-fu found the code itself on some other forum so I can't credit whoever wrote it. It appears to be working though! Quote Link to comment Share on other sites More sharing options...
ConMan Posted December 12, 2013 Author Share Posted December 12, 2013 Aaaaannnnnddddd then it didn't. With assembly open, then generated idw for assembly. When go to close drawing and save changes you get pop-up to include assembly in save. If you say yes you get following error message (second pic is the "more info" tab, of which the first line runs off to the side but is everything in pic 1): Functionally nothing appears to be wrong. All geometry updates correctly as does cg workpoint, it appears to just be a communication error. If you select "no" for the assembly when saving the drawing file, the drawing will save and close properly with no error code. Then when you close the assembly you save changes and it saves and closes fine with no error code. Anyone have any clue what might need to be tweaked? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.