Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing C/C component Automation

43 REPLIES 43
Reply
Message 1 of 44
shannonadmin
7634 Views, 43 Replies

Changing C/C component Automation

I'm looking at creating some Parametric models with Excel and ilogic

 

Anyone know if it’s possible to automate the changing of content centre components parts in a model using ilogic or some other method other than the traditional way of  manually selecting the components in the assembly followed by right mouse click to change

 

 As an example let say my model has some 1/2" hex bolts and I want to change them to 3/4" Hex Bolts is there a way to change these though a front end interface like and excel spreadsheet? or ilogic?

 

 Thanks

 

 N_M

43 REPLIES 43
Message 21 of 44
MjDeck
in reply to: cean_au

Cean,


 Here is a new version of the content center rule.  It has a new option to place a part with custom parameters as a Standard part.  The sample rule (AddContentCenterBar.txt) has a new line of code:
replacer.CreationMode = FileCreationMode.AsStandard

(Other options available are:
replacer.CreationMode = FileCreationMode.AsCustom

replacer.CreationMode = FileCreationMode.ByFunctionName  '  this is the default.  )

 I modified the sample code to work with the content center family that you are looking at.  This family uses a different custom parameter (B_L) to set the length (as compared to the pipe which uses PL).
 To see the parameter name, place a component manually and look at the Table View.  Hover the mouse over the column header to see the internal name of the column.  This is the parameter name that is required for the code.

ContentCenterColumnName.png


Mike Deck
Software Developer
Autodesk, Inc.

Message 22 of 44
MjDeck
in reply to: MjDeck

Note that I changed the sample code to use a parameter named BarLength (it was previously PipeLength).


Mike Deck
Software Developer
Autodesk, Inc.

Message 23 of 44

Mike,

You asked Cean if he wanted the part as stancard or custom. Can you explane the differences and an example of use for each?

 

Thank you

 

Jim

Jim

Inventor Premium 2013 SP1.1
Vault 2013- plain vanilla version
HP G71 notebook
celeron cpu w\ 4gb RAM and 64 bit system
Win 7 home premium

Ya, my boss has me running my personal machine at work.
Message 24 of 44
cean_au
in reply to: MjDeck

Hi Mike,

 

All good for custom part now. The flat bar is also good for standard, no matter I use "PL" or "B_L", or even omit it.

But the pipe still can't show correct length when placed as standard part.

 

Thanks

 

Cean

 

HI Jim, one difference is they are saved in different folders. Standard parts sit in content center. Custom ones sit in your project folder.

Message 25 of 44
MjDeck
in reply to: cean_au

Cean,
 Can you post your complete rule that demostrates the failure to set the length of the pipe component?  Please attach it as a text file.  That makes it easy for me to work with it.


Mike Deck
Software Developer
Autodesk, Inc.

Message 26 of 44
cean_au
in reply to: MjDeck

Here it is. Thx

Message 27 of 44
MjDeck
in reply to: cean_au

Cean,
 Your rule works on my system.  It creates a pipe with length PL = 200 in.
 On your system, you might have to manually delete old pipe parts in your Content Center directory.  The old version of the rule probably created parts with the wrong length.  The new version won't overwrite these: it doesn't know that they are obsolete.  Once you delete them, the rule can generate new versions.

 I think an old part would also explain the behavior you saw with the bar part.  When you use "PL" instead of "B_L" for the bar part: if the part with that name already exists, it won't try to regenerate it.  If it did, you would see that "B_L" is required.  Please try deleting your existing bar parts (only delete the recently generated ones: don't delete any that are being used in other assemblies) and generate new ones.  I'm pretty sure that you will find that "B_L" is required to set the length of the bar part.


Mike Deck
Software Developer
Autodesk, Inc.

Message 28 of 44
cean_au
in reply to: MjDeck

Hi Mike,

 

Cleaned the folders and all right now. The code is so cool now.

 

Thanks for all the help.

 

Cean

Message 29 of 44
MarkESmith
in reply to: shannonadmin

Hello

 

Could you please show a line of code which will swap content centre nuts?

 

also posted:

http://forums.autodesk.com/t5/Autodesk-Inventor/iLogic-Content-Center-Replace-Nuts/td-p/3489692

 

Many Thanks

 

MES

Message 30 of 44
MjDeck
in reply to: MjDeck

Mark,

 See the sample rule in the attached file SwapNut.txt.  It will select a different member row within a family.  With modifications, it could select a different family.  To make it work in an assembly, you need to change the name of the nut component (the component name in the Model browser, not the file name) to "Ansi B18.2.4.2M Nut:1".  Also, create a Text parameter named NutType.  Make it a multi-value parameter, with possible values:
M3x0.5
M4x0.7
M5x0.8

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 31 of 44
mehatfie
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

 

Message 32 of 44
mehatfie
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

Message 33 of 44
jefke1988
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?

Message 34 of 44
MjDeck
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
Autodesk, Inc.

Message 35 of 44
jefke1988
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

Message 36 of 44
Jefkee
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 2013
Message 37 of 44
Jefkee
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 2013
Message 38 of 44
Carthik_Babu
in reply to: MjDeck

Thank you very much Mike, for providing the code.
Just providing my project link, where i used your code and handled Excel File to insert content center component (i have not uploaded the file in this forum, since the file size is big)

http://grabcad.com/library/ilogic-content-center-1

Ilogic-content center - Copy.jpg

Hope it will be useful for some one, who searchs for the same

Other Ilogic Examples: http://grabcad.com/carthik-1/projects

Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/
Message 39 of 44
Carthik_Babu
in reply to: Carthik_Babu

Hi, modified excel and reduced size of the file. Uploading now. Only program written to insert component and ground shaft part and bearing as shown in the below image(which has different tree structure). Hope it will be useful for some one, who is looking for the same.

Content Center Tree.jpg

Ilogic-content center.jpg

Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/
Message 40 of 44
Carthik_Babu
in reply to: MjDeck

Dear Mr.Mike,

Your code works great....i need some clarfication, mentioned below.

 

i found the part inserted as custom by your code, still behave as content center file.

 

Whether is it possible to modify and apply the code available in the below forum, in your class and convert the placed  part as normal. 

http://forums.autodesk.com/t5/Autodesk-Inventor/Change-Content-Center-part-to-a-normal-ipt/m-p/39220...

 

 

 

Thanks in Advance 

Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/

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

Post to forums  

Autodesk Design & Make Report