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

    Autodesk Inventor

    Reply
    Mentor
    mehatfie
    Posts: 163
    Registered: ‎02-10-2012

    Re: Changing C/C component Automation

    11-20-2012 02:10 PM in reply to: MjDeck

    Hi Mike, (And other users who can help)

     

     

    EDIT  *** I've also posted the same message on the Customization forms at the following link for users who visit there more frequently:

     

    http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Automation-Replacing-Content-Center-Pa...

     

     

     

    You're code is definitley a great starting point, and will most likely save me a ton of time!

     

    I am currently diving into a small project which should save a lot of time for designers in the end if it pans out. 

     

     

    Issue being resolved:

     

    We use the Vault and have a ton of machines that get re-used from time to time through the Copy Design method. There's obviously some changes that are made from job to job, but the big issue is changing a machine from an Imperial to Metric one. This is the time (and mind) consuming process I'm looking to shorten.

     

     

    What I have:

     

    Currently I have a code (few tweaks needed but it works) that is run from an upper assembly. This code then cycles through each and every sub assembly and part that exists within it. As it cycles through, it checks for hole features which are tapped, and if it finds one of these instances, changes the thread from Imperial to Metric according to a Hard Coded set of values.

     

     

    Current Dilema:

     

    What's the point of changing the holes if the designer has to go through the assembly to change the bolts and fasteners anyways?

     

     

     

     

    I've practiced a bit with your code and been able to replace items, the issue is everything must be hard coded in order to do so. My question is: 

     

    Is there a way to get the Family from the Part Occurence / Document / Anything related?

     

     

     

    I've looked through the API, but have only found that everything related to the Content Center.... is only accessable through the Content Center, and nothing else.

     

    For Example, yes I am able to tell if a part has come from the content center (ie. PartComponentDefinition.IsContentMember), but that's as far as it goes, just a simple Boolean.

     

    There MUST be a way to find out some sort of Content Center information from the direct Part / other related documents. I've looked at the "Replace Content Center Part Sample" provided in the API, but this example hard codes the ContentTreeViewPath as well.

     

    In the end, I don't quite understand the point of hard coding this path with no way to access it through the Part Document. This only creates the need for constant manual change and / or MANY rules to compensate each and every family.

     

    Is there an easy answer to my dilemma?

     

     

    Thanks for the help in advance

    Mitch

     

    Please use plain text.
    Mentor
    mehatfie
    Posts: 163
    Registered: ‎02-10-2012

    Re: Changing C/C component Automation

    11-27-2012 06:29 AM in reply to: mehatfie

    Hi All,

     

    I've used a work around method and the code is pretty much complete. There is one error that's occuring which I do not understand.

     

    The code is successfully replacing bolts and various kinds, Flat Washers, Nuts... but for some reason, once it hits this LW it runs into an error (see attached photo).

     

    The following piece of code is where the error occurs, I use the same line throughout the rest of my code and it works fine. This same piece of code is what is used to replace the Flat Washers as well. What could be the cause of this Lock Washer error?

     

    The error line is between the messages:

     

    *Note: I Use this line of code earlier on to create the Column Object

     


    Dim NominalDiaColum As ContentTableColumn
    NominalDiaColum = CurrCCFamily.TableColumns.Item("NND")

     

     

    --------------------------------------------- Code ---------------------------------------

     

    'If this is a Washer
    Else If String.Compare(FastenerType, "Washers", True) = 0
         'Check Opposite Family For Part Size, Bolt Length, and a UNC Thread in the Imperial Part
         For Each oTableRow In OppCCFamily.TableRows

              Dim CurrentPartSize As Double
    MessageBox.Show("Test 3", "Title")
              CurrentPartSize = oTableRow.GetCellValue(NominalDiaColum)
    MessageBox.Show("Test 4", "Title")
              If (CurrentPartSize = OppPartSize) Then
                    OppPartNum = oTableRow.GetCellValue(PartNumberColum)
                    OppPartNumFound = True
                   'MsgBox("Found Washer Replacement")
                   Exit For
             End If
         Next
    End If

     

     

    ---------------------------------------- End Code --------------------------------

     

     

    Thanks 

    Mitch

    Please use plain text.
    Member
    Posts: 5
    Registered: ‎03-11-2013

    Re: Changing C/C component Automation

    03-11-2013 10:42 AM in reply to: mehatfie

    Hi,

     

    I'm trying to make the code work but i think i'm doing something horrobly wrong.

    Code link

     

    This is what i do.

     

    Step 1:

    Create a new assembly

     

    Step 2:

    Add external rule --> Tools --> options --> Ilogic configuration & add the code that is posted in ure thread.

     

    Step 3:

    Place a bolt in my assembly and name it "Bolt:1"

     

    Step 4:

    Add a rule for chaning the size of the bolt.

     

    AddVbFile "ContentCenterReplace.iLogicVb"
    
    If (BoltLength = 20) Then
    
      replacer.Replace("Bolt:1", familyName, "DIN 931-1 - M4 x 20")
    
    ElseIf  (BoltLength = 30) Then
    
      replacer.Replace("Bolt:1", familyName, "DIN 931-1 - M4 x 30")
    
    End If

     

    Step 5:


    I run the rule & get this error list

    Error on Line 130 : Type 'ComponentOccurrence' is not defined.
    Error on Line 143 : Type 'Document' is not defined.
    Error on Line 161 : Type 'Document' is not defined.
    Error on Line 163 : Type 'PartDocument' is not defined.
    Error on Line 164 : Type 'Parameters' is not defined.
    Error on Line 197 : Type 'Parameters' is not defined.
    Error on Line 198 : Type 'Inventor.Parameter' is not defined.
    Error on Line 217 : Type 'Document' is not defined.
    Error on Line 218 : Type 'Inventor.Application' is not defined.
    Error on Line 219 : Type 'AssemblyDocument' is not defined.
    Error on Line 225 : Type 'Document' is not defined.
    Error on Line 225 : Type 'Application' is not defined.
    Error on Line 229 : Type 'AssemblyDocument' is not defined.
    Error on Line 265 : Type 'ComponentOccurrence' is not defined.
    Error on Line 277 : Type 'ComponentOccurrence' is not defined.
    Error on Line 286 : Type 'ComponentOccurrence' is not defined.
    Error on Line 287 : Type 'AssemblyComponentDefinition' is not defined.
    Error on Line 288 : Type 'Inventor.ComponentOccurrence' is not defined.
    Error on Line 303 : Type 'Document' is not defined.
    Error on Line 315 : Type 'Document' is not defined.
    Error on Line 316 : Type 'DocumentDescriptor' is not defined.
    Error on Line 330 : Type 'Application' is not defined.
    Error on Line 340 : Type 'Application' is not defined.
    Error on Line 368 : Type 'ContentFamily' is not defined.
    Error on Line 374 : Type 'ContentFamily' is not defined.
    Error on Line 376 : Type 'ContentTableColumn' is not defined.
    Error on Line 380 : Type 'ContentTableRow' is not defined.
    Error on Line 390 : Type 'ContentTreeViewNode' is not defined.
    Error on Line 395 : Type 'ContentFamily' is not defined.
    Error on Line 404 : Type 'ContentTreeViewNode' is not defined.
    Error on Line 413 : Type 'ContentTreeViewNode' is not defined.
    Error on Line 415 : Type 'ContentFamily' is not defined.
    Error on Line 422 : Type 'ContentTreeViewNode' is not defined.
    Error on Line 434 : Type 'ContentFamily' is not defined.
    Error on Line 436 : Type 'ContentFamily' is not defined.
    Error on Line 454 : Type 'ContentTreeViewNode' is not defined.
    Error on Line 454 : Type 'ContentFamily' is not defined.
    Error on Line 459 : Type 'ContentFamily' is not defined.
    Error on Line 468 : Type 'ContentTreeViewNode' is not defined.
    Error on Line 476 : Type 'ContentTreeViewNode' is not defined.
    Error on Line 476 : Type 'ContentTreeViewNode' is not defined.
    Error on Line 480 : Type 'ContentTreeViewNode' is not defined.
    Error on Line 489 : Type 'ContentFamily' is not defined.
    Error on Line 489 : Type 'ContentTableColumn' is not defined.
    Error on Line 491 : Type 'ContentTableColumn' is not defined.
    Error on Line 505 : Type 'ContentFamily' is not defined.
    Error on Line 512 : Type 'ContentTableColumn' is not defined.
    Error on Line 524 : Type 'ContentTableColumn' is not defined.
    Error on Line 539 : Type 'ContentTableRow' is not defined.
    Error on Line 568 : Type 'ContentFamily' is not defined.
    Error on Line 568 : Type 'ContentTableRow' is not defined.
    Error on Line 572 : Type 'NameValueMap' is not defined.
    Error on Line 582 : Type 'Inventor.MemberManagerErrorsEnum' is not defined.
    Error on Line 584 : Type 'Inventor.ContentMemberRefreshEnum' is not defined.
    Error on Line 623 : Type 'NameValueMap' is not defined.

     

    What am i doing wrong? any help?

    Please use plain text.
    Employee
    Posts: 932
    Registered: ‎02-24-2009

    Re: Changing C/C component Automation

    03-11-2013 11:56 AM in reply to: jefke1988

    jefke1988,

     You are missing some important statements in your rule. Add these lines after the AddVbFile line:

    Dim replacer As New ContentCenterReplace(ThisDoc.Document, ThisApplication, "en-US")

    Dim familyName As String = "Fasteners:..."

     

    You have to enter the complete family name, which would be similar to:

    "Fasteners:Nuts:Hex:ANSI B18.2.4.2M"



    Mike Deck
    Software Developer
    DLS - Mechanical Design
    Autodesk, Inc.

    Please use plain text.
    Member
    Posts: 5
    Registered: ‎03-11-2013

    Re: Changing C/C component Automation

    03-11-2013 12:37 PM in reply to: MjDeck

    Ok, got it sorted now & adjusted to my needs!

     

    AddVbFile "ContentCenterReplace.txt"
    Dim replacer As New ContentCenterReplace(ThisDoc.Document, ThisApplication, "en-US")
    Dim familyName As String = "Fasteners:Bolts:Hex Head:DIN 931-1 - replaced by DIN EN 24014"
    
    replacer.Replace("Bolt:1", familyName, "DIN 931-1 - M" & BoltSize & " x " & BoltLength)

     

    Works like a charm! all we ever needed! TYVM

    Please use plain text.
    Contributor
    Posts: 24
    Registered: ‎09-26-2012

    Re: Changing C/C component Automation

    04-26-2013 03:35 AM in reply to: jefke1988

    Hi, again,

     

    Is it possible to change custom content center part (change size)?

     

    and

     

    replace content center parts with a custom parameter (tubes etc)?

     

    If Yes how is it done?

    Inventor 2012
    Please use plain text.
    Contributor
    Posts: 24
    Registered: ‎09-26-2012

    Re: Changing C/C component Automation

    04-30-2013 07:23 AM in reply to: Jefkee

    Ok. I didn't saw the second page of this thread (must have skipped it).

     

    I got the example with the tube working. But, now i want to use it on my custom part & it's not working..

    I have this flange that i made, the idea is that it can have any neck thickness so that is a free parameter.

     

    This is the code where i can change the size (except the thickness) as standerd part.

    AddVbFile"ContentCenterReplace.txt"

    DimreplacerAsNewContentCenterReplace(ThisDoc.Document, ThisApplication, "en-US")DimfamilyNameAsString="Ellimetal:Flenzen:EN 1092-1 - WN - RF"

    replacer.Replace("Flens:1", familyName, "WN Flange DN"&Maat&" - PN"&Rating&" - RF - EN1092-1 (t=1,6mm)")

    Now i add the flange as custom into my part and tried this code.

    AddVbFile"ContentCenterReplace.txt"

    DimreplacerAsNewContentCenterReplace(ThisDoc.Document, ThisApplication, "en-US")DimfamilyNameAsString="Ellimetal:Flenzen:EN 1092-1 - WN - RF"
    DimstandardpartNameAsString="WN Flange DN"&Maat&" - PN"&Rating&" - RF - EN1092-1 (t=1,6mm)"
    DimcustomPartNameAsString="WN Flange DN"&Maat&" - PN"&Rating&" - RF - EN1092-1 (t="&Dikte&"mm)"

    replacer.ReplaceCustom("Flens:1", pipeFamilyName, standardPartName, customPartName, "Flens_DimT", Dikte)

    (Flens_DimT) is the parameter to set the neck thickness.

     

     

    This is my error msg:

    Error in rule: Flens:1, in document: Test 911.iam
    
    Object reference not set to an instance of an object.

     

    System.NullReferenceException: Object reference not set to an instance of an object.
       at ContentCenterFinder.ParseLevels(String pathName)
       at ContentCenterFinder.FindFileName(String familyPathName, String partNumber, CustomInformation customInfo)
       at ContentCenterReplace.ReplaceCustom(ComponentOccurrence occurrence, String ccPath, String partNumber, String fileName, Object[] customNamesAndValues)
       at LmiRuleScript.Main()
       at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
       at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

     

     

    What is wrong??

     

     

     

    Edit: found it, thanks for this wonderfull code.

     

    had a copy paste error omg.

    Inventor 2012
    Please use plain text.