• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    Contributor
    Passi
    Posts: 13
    Registered: 03-24-2011
    Accepted Solution

    Suppression of a hole feature with VBA instead of ilogic

    114 Views, 4 Replies
    02-07-2012 05:12 AM

    Hi,

     

    In ilogic it's easy to suppress features like holes, but I cannot combine iparts with Ilogic, so I try the same in VBA, but I don't know the way to do it :smileyhappy:

     

    Is there some existing sample code like this ilogic one for VBA?:

     

    if Dimension_A < 50 Then

    Feature.IsActive("Hole1") = false 

    End if 

     

    Best Regards

     

    Passi  

    Employee
    Posts: 867
    Registered: 02-24-2009

    Re: Suppression of a hole feature with VBA instead of ilogic

    02-07-2012 04:37 PM in reply to: Passi

    In iParts, you don't need VBA.  You can add a column for suppression of a feature to the iPart table.  It is on the Suppression tab in the iPart Author dialog.



    Mike Deck
    Software Developer
    MFG-Digital Engineering
    Autodesk, Inc.

    Contributor
    Passi
    Posts: 13
    Registered: 03-24-2011

    Re: Suppression of a hole feature with VBA instead of ilogic

    02-08-2012 04:06 AM in reply to: Passi

    Ok, I think, I have to explain it a little bit more in detail, why I want to try it with VBA.

     

    We're trying to build a 3D parts library for our standard company parts.

     

    Some of these parts are simple flanges etc. So, they are very easy to build as an ipart.

     

    But we also have a lot of highly customizable parts. For example: There’s one part with the following variants:

     

    It’s some sort of a cylindrical body with inlet and outlet. The inlet has different sizes and inclinations and also the outlet. Also the cylindrical part has different sizes, which is defined by the sizes of inlet and outlet. And then, the inlet and outlet has a user defined position to each other (from 85° to 270°) in some cases the inclination of the inlet and outlet limits this position. And sometimes there is more than one outlet.

    Now, we can build up a parametric model (ilogic) which rules every variant (I made it with ilogic and it worked).

    So at least we only want to have the main 13 sizes and the other variants are defined by the user when he inserts this part. 

    But ipart and illogic doesn’t work together. You can only use ipart or illogic.

    Ilogic itself is not enough to manage it (We have to build up a lot of parts).

    And only iparts we have to build up thousands of table entries.

     

    The possibility I thought was, to use VBA instead of illogic. Because Iparts seems to work with VBA. But to clearify that VBA and iparts really working together, we have to check it first, and that why I asked that.

    Later on, we want to build up a company content library with an interface like the screw interface, where the user only set the 6 or 7 parameters and then the model is generated.

    Employee
    Posts: 867
    Registered: 02-24-2009

    Re: Suppression of a hole feature with VBA instead of ilogic

    02-08-2012 09:16 AM in reply to: Passi

    Passi,

    Another thing that might help is condtional suppression of features.  You can drive feature suppression directly from a parameter value, and you don't need a separate column in the iPart table.
     To use conditional suppression, right-click on the feature in the browser tree and select Properties.  You can enter the condition in this dialog:
    Hole1ConditionalSuppression.png

     

     

    I'm not sure if VBA will do what you want.  Note that the features from the factory are not present in the iPart member files.  Each member file has a derived solid body from the factory.

     

    If you want to try VBA, here is an iLogic rule that uses the Inventor API to do the same thing as your original rule.  It can be easily converted to VBA.

     

    Dim partDoc as PartDocument = ThisApplication.ActiveDocument

    Dim features As PartFeatures = partDoc.ComponentDefinition.Features
    Dim hole1Feature As PartFeature = features("Hole1")

    If Dimension_A < 50 Then
      hole1Feature.Suppressed = True
    Else
      hole1Feature.Suppressed = False
    End If



    Mike Deck
    Software Developer
    MFG-Digital Engineering
    Autodesk, Inc.

    Contributor
    Passi
    Posts: 13
    Registered: 03-24-2011

    Re: Suppression of a hole feature with VBA instead of ilogic

    02-09-2012 05:23 AM in reply to: Passi

    Thanks for this answer. It solves two problems at once :smileyhappy:

     

    I tried it with the VBA first, but it seems to make the model instable. Because Inventor crahses a few times, when I insert the parts.

     

    But now, I combined both. The feature property with the VBA. In VBA calculate the condition 

    ___________________

     

    Public Function Condition1(Dim_A As Double) As Double
    Dim_A = Dim_A * 10
    Condition1 = 0

    If Dim_A >= 50 And Dim_A <= 100 Then

    Condition1 = 1
    End If

    End Function

    ___________________ 

     

    And then I use the Condition1 to say suppress the Hole1 or not.

     

    Thanks a lot, that saved me a lot of table work :smileyhappy:

     

    Now, I'm thinking about the content center folders (because in the moment, Inventor is saving the content files in the main directory of my vaut system (designs) and thats not the optimum :smileyhappy:)