Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Am I updating my files incorrectly (VB Question)

6 REPLIES 6
Reply
Message 1 of 7
nickv02
1029 Views, 6 Replies

Am I updating my files incorrectly (VB Question)

I have a standalone VB program in VB2010 Express that I am using to read parameters from an Excel file, and in turn update the parameters of an Inventor Assembly, and print drawings based off this.

 

The assemblies are sheet metal doors. 

 

I have a drawing master file, which contains all the sketches I use to derive my parts and in turn create an assembly.

 

The problem I am having is, to me, it seems like the files are either not updating correctly, or the process is going too quickly that it doesn't have time to update.  When the door size changes from 36"W x 84"H to 48"W x 96"H, for instance, parts of the internal door assembly are left sticking out, as if they didn't have time to register the size change and regroup, and are stuck in mid-air while the program continues on it's way.  (See PDF's attached)

 

My VB structure looks something like this:

 

_invApp.SilentOperation = True

'open the master drawing files for the door and frame _invApp.Documents.Open("drawing_master_file.ipt") _invApp.ActiveDocument.Update() _invApp.ActiveDocument.Save() _invApp.ActiveDocument.Close() 'open each piece of the assembly to update the files _invApp.Documents.Open("each_individual_part_of_the_door_and_frame.ipt") _invApp.ActiveDocument.Update() _invApp.ActiveDocument.Save() _invApp.ActiveDocument.Close() 'open and update the frame assembly _invApp.Documents.Open("complete_frame_assembly.iam") _invApp.ActiveDocument.Update() _invApp.ActiveDocument.Save() _invApp.ActiveDocument.Close() 'open and update the door assembly _invApp.Documents.Open("complete_door_assembly.iam") _invApp.ActiveDocument.Update() _invApp.ActiveDocument.Save() _invApp.ActiveDocument.Close() 'open and update the final assembly model _invApp.Documents.Open("final_assembly_door_and_frame.iam") _invApp.ActiveDocument.Update() _invApp.ActiveDocument.Save() _invApp.ActiveDocument.Close() 'open, update, and print drawing file for the final assembly _invApp.Documents.Open("drawing_file.idw") _invApp.ActiveDocument.Update() _invApp.ActiveDocument.Save() _invApp.ActiveDocument.Close()

 I am hoping I conveyed my problem clearly.  If not, please let me know.

 

 

6 REPLIES 6
Message 2 of 7
Vladimir.Ananyev
in reply to: nickv02

Let’s try slightly different and simplified sequence of open/update/save/close operations. 

1. Open, update and save "drawing_master_file.ipt" and leave it in memory.  There is no sense to close it, because it will be opened in background on the every next step.  You may open models invisibly for faster operations. 

2. Open final assembly model.  All dependent parts and subassemblies (frame, door) will be opened in background automatically.  Update (may be you need update your model twice).  Then use CommandManager functionality to run Inventor command SaveAll (The following command names are useful in your case: AppSaveAllCmd and

AppCloseAllCmd. See Brian Ekins post

http://modthemachine.typepad.com/my_weblog/2009/03/running-commands-using-the-api.html ). 

Leave main assembly in memory. 

3. Open drawing file.  Update and save it, then check for errors. 

In the end you may run AppCloseAllCmd command to close all files that are currently in memory.

At debug cycle use option _invApp.SilentOperation = False to see Inventor messages.

 

Let us know the results, please.  (and Inventor version too)

 

P.S.

You may use Application.Documents() collection to monitor files in memory at any time of your procedure.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 7
nickv02
in reply to: Vladimir.Ananyev

Vladimir, thank you for your response.  I have tried your method and the error in my drawing files still occurs.  However, I believe I have narrowed down the culprit to something other than the updating process. 

 

I am using Inventor 2013 and VB Express 2010 to write the standalone .exe.

 

Here is where I believe my issue lies:

 

Within each door and frame are table rows, as they are both iAssemblies.  The table row changes based on the lockset cutout in the door, the hinge cutouts in the frame, and whether or not there is a piece of glass in the door as a vision cutout.  So when the .idw drawing opens, the code has to tell the drawing views which 'model state' it wants to choose. 

 

As it turns out, the drawing will gladly update itself and it's views if the model state, or table row, changes from one drawing to the next.  I.e. if the first door has a different lockset from the second door.  However, if both doors and frames are the same, with only the physical size dimensions being different, the table row doesn't update, and for some reason, when the table rows and model states don't change, the drawing doesn't want to refresh itself, so it doesn't fully update or regenerate the views to show the sizes correctly.

 

I have tested my theory by inputting different door dimensions but leaving the other properties the same, and the drawings end up flubbed.  And when I change the other properties between parts, the drawings update perfectly.

 

So, here is the code I use to switch model states within the .idw, based on what has been input.  Am I going about this process correctly?  Is there a regenerate command I'm missing?  Or redraw command?

 

_invApp.Documents.Open("\\DSDC02\CAD Projects\Products\Marine\Doors & Frames\IMO\Drawings\Joiner_A60_RHR_B1_F6_V_Submittal_Sheet.idw")
Dim oDocDrwg As DrawingDocument
oDocDrwg = _invApp.ActiveDocument()
oDocDrwg.Update()
'oDocDrwg.Update2()
Dim oView1 As DrawingView
Dim oView2 As DrawingView
Dim oView3 As DrawingView
Dim oView4 As DrawingView
Dim oView5 As DrawingView

If vValue_Lockset1 = "Dorma ML9956 Entry Mortise Lock" Or vValue_Lockset1 = "Dorma ML9010 Passage Mortise Latch" Then

If vValue_Hinge1 = "SL300, Select Continuous Hinge, SS" Then
'----------------------------------------------------
'Test for iAssembly Row for Drip Cap and Sill Cap
'----------------------------------------------------
If vValue_DripCap = "Y" And vValue_SillCap = "Y" Then
oView1 = oDocDrwg.Sheets(1).DrawingViews(1)
oView1.ActiveMemberName = "F6_A60_RHR_B1_V_Assembly-01"
oView2 = oDocDrwg.Sheets(1).DrawingViews(2)
oView2.ActiveMemberName = "F6_A60_RHR_B1_V_Assembly-01"
oView3 = oDocDrwg.Sheets(1).DrawingViews(3)
oView3.ActiveMemberName = "F6_A60_RHR_B1_V_Assembly-01"
oView4 = oDocDrwg.Sheets(1).DrawingViews(4)
oView4.ActiveMemberName = "F6_A60_RHR_B1_V_Assembly-01"
oView5 = oDocDrwg.Sheets(1).DrawingViews(5)
oView5.ActiveMemberName = "F6_A60_RHR_B1_V_Assembly-01"

ElseIf vValue_DripCap = "Y" And vValue_SillCap = "N" Then
oView1 = oDocDrwg.Sheets(1).DrawingViews(1)
oView1.ActiveMemberName = "F6_A60_RHR_B1_V_Assembly-02"
oView2 = oDocDrwg.Sheets(1).DrawingViews(2)
oView2.ActiveMemberName = "F6_A60_RHR_B1_V_Assembly-02"
oView3 = oDocDrwg.Sheets(1).DrawingViews(3)
oView3.ActiveMemberName = "F6_A60_RHR_B1_V_Assembly-02"
oView4 = oDocDrwg.Sheets(1).DrawingViews(4)
oView4.ActiveMemberName = "F6_A60_RHR_B1_V_Assembly-02"
oView5 = oDocDrwg.Sheets(1).DrawingViews(5)
oView5.ActiveMemberName = "F6_A60_RHR_B1_V_Assembly-02"

 

Message 4 of 7
nickv02
in reply to: nickv02

FYI, I found documentation on a Rebuild command that I thought would be useful, but as it turns out it didn't do anything to remedy the situation. 

 

I added it to both the final assembly code and the drawing code, but it didn't help unfortunately.

 

_invApp.Documents.Open("\\DSDC02\CAD Projects\Products\Marine\Doors & Frames\IMO\F6\F6_A60_RHR_B1_V_Assembly.iam")
 Dim F6A60RHRB1V As AssemblyDocument
F6A60RHRB1V = _invApp.ActiveDocument
F6A60RHRB1V.Update()
F6A60RHRB1V.Rebuild()
F6A60RHRB1V.Save()

 

Message 5 of 7
Vladimir.Ananyev
in reply to: nickv02

Hi nickv02

 
Have you ever consider iLogic to control doors configurations as the powerful alternative to iAssembly / iPart ?
 iLogic rules use similar to VB.NET syntax, so you can easily test it. IMHO you may save a lot of time with iLogic in your designs.
 

Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 6 of 7
nickv02
in reply to: Vladimir.Ananyev

No I hadn't really gone that direction. 

Message 7 of 7
Vladimir.Ananyev
in reply to: nickv02

I believe the following two excellent classes from Autodesk University 2011 should be very interesting in your context.

 

CP2544  “Autodesk Inventor iLogic or Inventor API: Which Is the Right Tool for Me?”   by Wayne Brill (Autodesk).   Compares the capabilities of iLogic with the Inventor API.

 

ME3984  “Automate Your Curtain Wall, Window, and Building Product Design with Autodesk Inventor”   by Joe Bartels and Bill Graham (Enclos Corp.).  iLogic and other Inventor tools  for windows/doors/curtain wall design.

 

You can download them here:   http://au.autodesk.com/?nd=online_learning

 

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report