help with a vba program

help with a vba program

Anonymous
Not applicable
712 Views
5 Replies
Message 1 of 6

help with a vba program

Anonymous
Not applicable

Once again I am working in Inventor.  Once again I am designing a casting part.  I want to create two views/representations of the part - one with just the casting features and one with the casting features plus holes and extruded cuts (used for surfacing).  Unfortunately, Inventor STILL doesn't have the ability to suppress features based on representations.  This makes me very sad.

 

Before I move over to SolidWorks AGAIN, I wanted to give it one more college try.

 

Below is a VB code sample where I look at which viewrepresentation is active.  If the casting version is active, the features are suppressed.  If the machined version is active the features are unsuppressed.  However, it doesn't work.

 

I also tried to run this as an iLogic rule, but I couldn't figure out how to set up the iTrigger.

 

Any help is appreciated.  I can't believe we are on Release 2014 and Inventor still doesn't manage castings without using derived parts.

 

 

 

 

 

 

===================================================

Public Sub Casting_Part()

Select Case ViewRep
Case "Casting Only"
oThisCompDef.RepresentationsManager.DesignViewRepresentations.Item("Casting Only").Activate
' ***Base Mounting Hole***
Feature.IsActive("Base Mounting Hole") = False

' ***captive screw hole 1***
Feature.IsActive("captive screw hole 1") = False

' ***captive screw hole 2***
Feature.IsActive("captive screw hole 2") = False

' ***captive screw hole 3***
Feature.IsActive("captive screw hole 3") = False

' ***bottom counterbore for captive screws***
Feature.IsActive("bottom counterbore for captive screws") = False

' ***bottom counterbore for captive screws***
Feature.IsActive("bottom counterbore for captive screws") = False

' ***4-40 corner hole 1***
Feature.IsActive("4-40 corner hole 1") = False

' ***4-40 corner hole 2***
Feature.IsActive("4-40 corner hole 2") = False

' ***4-40 corner hole 3***
Feature.IsActive("4-40 corner hole 3") = False

' ***4-40 landing 1***
Feature.IsActive("4-40 landing 1") = False

' ***4-40 landing 2***
Feature.IsActive("4-40 landing 2") = False

' ***4-40 landing 3***
Feature.IsActive("4-40 landing 3") = False

' ***4-40 landing 4***
Feature.IsActive("4-40 landing 4") = False

' ***center heatsink 4-40***
Feature.IsActive("center heatsink 4-40") = False

' ***MOUNTING LANDS 2 FRONT 4-40***
Feature.IsActive("MOUNTING LANDS 2 FRONT 4-40") = False

' ***LASER LAND 2-56***
Feature.IsActive("LASER LAND 2-56") = False


Case "Surfacing and Taps"
oThisCompDef.RepresentationsManager.DesignViewRepresentations.Item("Surfacing and Taps").Activate

' ***Base Mounting Hole***
Feature.IsActive("Base Mounting Hole") = True

' ***captive screw hole 1***
Feature.IsActive("captive screw hole 1") = True

' ***captive screw hole 2***
Feature.IsActive("captive screw hole 2") = True

' ***captive screw hole 3***
Feature.IsActive("captive screw hole 3") = True

' ***bottom counterbore for captive screws***
Feature.IsActive("bottom counterbore for captive screws") = True

' ***bottom counterbore for captive screws***
Feature.IsActive("bottom counterbore for captive screws") = True

' ***4-40 corner hole 1***
Feature.IsActive("4-40 corner hole 1") = True

' ***4-40 corner hole 2***
Feature.IsActive("4-40 corner hole 2") = True

' ***4-40 corner hole 3***
Feature.IsActive("4-40 corner hole 3") = True

' ***4-40 landing 1***
Feature.IsActive("4-40 landing 1") = True

' ***4-40 landing 2***
Feature.IsActive("4-40 landing 2") = True

' ***4-40 landing 3***
Feature.IsActive("4-40 landing 3") = True

' ***4-40 landing 4***
Feature.IsActive("4-40 landing 4") = True

' ***center heatsink 4-40***
Feature.IsActive("center heatsink 4-40") = True

' ***MOUNTING LANDS 2 FRONT 4-40***
Feature.IsActive("MOUNTING LANDS 2 FRONT 4-40") = True

' ***LASER LAND 2-56***
Feature.IsActive("LASER LAND 2-56") = True
End Select

End Sub

0 Likes
713 Views
5 Replies
Replies (5)
Message 2 of 6

Curtis_Waguespack
Consultant
Consultant

Hi elise_moss,

 

I'll have a look at the code and report back if I have anything to report, but I wanted to point out that many people use iParts to handle this. Have you explored iParts for castings? iParts should allow you to detail the part in the drawing using different members of the iPart factory for each manufacturing stage.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 3 of 6

Anonymous
Not applicable

I was able to create the iPart table no problem.  Is there any way to re-organize the columns?  I want to re-arrange them.

 

I will have to see how the drawing goes to see, but this might be an easy solution.

 

Thanks,

0 Likes
Message 4 of 6

Curtis_Waguespack
Consultant
Consultant

Hi elise_moss,

 

Once you have the table created, you can locate the Table node in the browser and then right-click on it and choose Edit via Spreadsheet and then cut and paste columns as needed to organize them. Keep in mind that Inventor will stop reading the data when it encounters a blank column header, so make sure you don't accidentally end up with a blank column (but blanks columns can be used to our advantage in some other workflows).

 

As for the drawing, when you place or edit the view, go to the Model State tab, and then choos the member row that represents the casting's manufacturing step that you want to use for that particular view.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 5 of 6

EliseMoss
Enthusiast
Enthusiast

Thanks, Curtis...got the table looking the way I wanted.

Went over to a drawing and unable to place any views from the part.

 

I get an error saying that the selected file is an "out of date factory that has no generated members for view creation". 

 

I am able to activate each member of the table.  I have saved the file. 

 

There is no generate button.  and, guess what?  NOTHING in the Inventor help on how to deal with the error message.  I did see several posts on the forum from members who also have experienced this dialog, gave up and moved over to SolidWorks. 

 

I'm a little more stubborn...d*n it, I will MAKE Inventor work if I possibly can!

 

now what?

 

 

0 Likes
Message 6 of 6

EliseMoss
Enthusiast
Enthusiast

OK, here is what I did as my work-around - opened an assembly file - which I DIDN'T NEED AND DIDN'T WANT - placed one instance of each member of the ipart into the assembly.  This generated the members.  I then was able to create the views and place them in my drawing.

 

I just checked and once I closed the assembly file (without saving it), no extra part files were created, which is what I was trying to avoid, so it looks like I am OK.

 

Still about twice as much work as what SolidWorks requires and I am not 100% sure that I am going to get decent results, but fingers crossed.

0 Likes