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
7631 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 2 of 44
MjDeck
in reply to: shannonadmin

I think it is possible with iLogic, but it requires a lot of API code.  I will look at it and try to post a solution.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 44
shannonadmin
in reply to: MjDeck

Great

 

Thanks Mike

Message 4 of 44
shannonadmin
in reply to: MjDeck

Hey Mike

 

Did you find the information I require?

 

Please dont forget me

 

N_M

Message 5 of 44
MjDeck
in reply to: shannonadmin

Are you using Inventor 2011?  I think there is a way in 2011, but I don't know about previous versions.


Mike Deck
Software Developer
Autodesk, Inc.

Message 6 of 44
shannonadmin
in reply to: shannonadmin

I'm on subscription so I have the latest version 2011, please share with me what you have learnt ?

 

N_M

Message 7 of 44
MjDeck
in reply to: shannonadmin

Here is a way to do it using iLogic in Inventor 2011.  Most of the code is in an external rule, so that it can be re-used.  This code is provided "as is".

 

Save the attached file (ContentCenterReplace.iLogicVb) to a directory on your machine.  Add that directory to the list of External Rule Directories under Tools -> Options -> iLogic Configuration.

 

 To use this method, you have to rename the component occurrence in the assembly Model Browser (this way it has a constant name and iLogic can find it).  The attached screenshot (CCOccurrenceRename.PNG) shows how this looks in my sample model.  The disadvantage of this is that you don't see the component size information in the tree. You have to right-click on the component and look at the iProperties.

 

 Here's a sample rule:

 

AddVbFile "ContentCenterReplace.iLogicVb"
Dim replacer As New ContentCenterReplace(ThisDoc.Document, ThisApplication, "en-US")
Dim familyName As String = "Fasteners:Bolts:Hex Head:Hex Cap Screw - Metric"
compo = Component.InventorComponent("Hex Cap Screw:2")
replacer.Replace(compo, familyName, CapScrew2Name)

AddVbFile "ContentCenterReplace.iLogicVb"
Dim replacer As New ContentCenterReplace(ThisDoc.Document, ThisApplication, "en-US")
Dim familyName As String = "Fasteners:Bolts:Hex Head:Hex Cap Screw - Metric"
compo = Component.InventorComponent("Hex Cap Screw:2")

replacer.Replace(compo, familyName, CapScrew2Name)

Note the "en-US".  If you use a different language in Content Center, you will have to change this.  I haven't tested it with other languages. 

 

The familyName is the complete path to the part, using a colon as the separator.

 CapScrew2Name is a Text parameter in the assembly.  In this case it's a multivalue parameter, with values such as

ANSI B18.2.3.1M - M10 x 70 - 15

You can use either the Part Number or the File Name from the Table View of the Content Center family.

 

Here's another example with hard-coded part numbers:

If (ScrewLength = 55) Then

  replacer.Replace("Hex Cap Screw:1", familyName, "ANSI B18.2.3.1M - M10 x 1.5 x 55")

ElseIf  (ScrewLength = 65) Then

  replacer.Replace("Hex Cap Screw:1", familyName, "ANSI B18.2.3.1M - M10 x 1.5 x 65")

End If

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 8 of 44
josephcooley
in reply to: MjDeck

Mike,

Has there been any other solution developed for this problem?  Will this be a standard feature in 2012?  I think this is an extremely usefull feature for Inventor.

Message 9 of 44
MjDeck
in reply to: josephcooley

I'm not sure if there's another solution.  Did you try the external rule and sample internal rule that I posted?  If so, are there any improvements or changes that you think it needs?

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 10 of 44
josephcooley
in reply to: MjDeck

The only thing I am worried about is that this file will be traveling...  So it will be used by many users on different computers.  Will that file always have to be available in the correct path on any computer that it is used on.  If its a one time thing then that will probably work if not I may need to find a different route.

Message 11 of 44
MjDeck
in reply to: josephcooley

Instead of putting it in a global folder, you can store the external rule file in the same folder as the assembly, or in the project workspace folder.  Then it's easier to transfer it along with the model.


Mike Deck
Software Developer
Autodesk, Inc.

Message 12 of 44
josephcooley
in reply to: MjDeck

ok well i can do that for now but will this be a standard feature in Inventor 2012?  This would be very usefull.

Message 13 of 44
MjDeck
in reply to: josephcooley

We don't have plans to add it as a standard feature in Inventor 2012.  But maybe in a later version.


Mike Deck
Software Developer
Autodesk, Inc.

Message 14 of 44
cean_au
in reply to: MjDeck

hi,

 

I tried this one on 2012.

 

If I want to raplace a length 15 one to Length 55 one, it told me the length 55 one can't be found.

 

It seems to me, I have to create the L55 one first.

 

Just wondering if I could creat a L55 one at first place.

 

Thx

 

Cean

Message 15 of 44
MjDeck
in reply to: MjDeck

Cean,

 Do you want to create a custom or a standard component?  Is there a row with Length = 55 already listed in the CC table, or is Length a free parameter that is not limited to a fixed list of values?  If it is a free parameter, you would use the ReplaceCustom function instead of Replace. I have attached a new version of the external rule which has this function.  Also attached is sample code that shows how it might be used.

To use this sample, you would create a numeric parameter named  PipeLength   in your assembly.  Set the value of this parameter to the length of the pipe you want.

 If this new version and sample don't help you, please provide more details and post your rule code.


Mike Deck
Software Developer
Autodesk, Inc.

Message 16 of 44
cean_au
in reply to: MjDeck

Hi Mike,

 

I can change the length now with your replace code.

 

But I am more interested in creating the length i want whitout a replace. If I specify the part file name directly with length, like the code below, I got an error. 

 

    strContentPartFileName = "ASTM A 53_A 53M Pipe 1_8 - Schedule 40 - 100"
	
    Dim oMat As Matrix
     oMat = ThisApplication.TransientGeometry.CreateMatrix

    ' Insert an instance of the content center member in the assembly.
    Call oDoc.ComponentDefinition.Occurrences.Add(strContentPartFileName, oMat)

 

 if i use CreateMemeber method, I can't set the length.

 

strContentPartFileName = oFamily.CreateMember(1, myError, strErrorMessage)

 

 

Thanks for help.

 

Cean

Message 17 of 44
MjDeck
in reply to: cean_au

Cean,

 Here's a new version of ContentCenterReplace.txt.  It has two new functions: GetPartFullFileName and  GetCustomPartFullFileName.  These will a create a part file (if required) and return the full file path name (including the directory).  You can use this name to add a new component to an assembly.  See the sample code in AddContentCenterComponent.txt.


Mike Deck
Software Developer
Autodesk, Inc.

Message 18 of 44
cean_au
in reply to: MjDeck

Hi Mike,

 

I tried your new code and got an error saying:

 

System.ArgumentNullException: Value cannot be null.
Parameter name: path1
   at System.IO.Path.Combine(String path1, String path2)
   at ContentCenterFinder.GetOrCreateFilename(ContentFamily family, ContentTableRow row, String fileNameCellValue)

 After trace the code, I found in Function GetOrCreateFilename, CustomPartDirectory doesn't have a value.

I set CustomPartDirectory="c:\" and got the part with the length I wanted. This is a custom part.

 

one more thing, I tryied to place it as a standard part by set isCustom=Flase inside GetOrCreateFilename function, it seems to me I can only get the length of '10'. not any length I want.

 

I am very happy that now I can place a custom part in any length. Thanks for your time.

 

Regards,

 

Cean

Message 19 of 44
MjDeck
in reply to: cean_au

Cean,

 If you save your assembly at least once before using the rule, then it will automatically set CustomPartDirectory to the directory of your assembly.  That's the way I would recommend using it.

 I think I can improve the code so that you can specify custom parameters, and at the same time generate the part as a standard part.


Mike Deck
Software Developer
Autodesk, Inc.

Message 20 of 44
cean_au
in reply to: MjDeck

Hi Mike,

 

Yes, the saving did the trick.

 

But when I try another material like this, say 200 length:

Dim PfamilyName As String = "Structural Shapes:Square/Rectangular/Hex Bars:ISO 1035/3 - 1980"
Dim standardPartName As String = "ISO 1035_3 - 60 x 10 - 0.001"
Dim customPartName As String = "ISO 1035_3 - 60 x 10 - " & PipeLength

 I can get the correct filename: ISO 1035_3 - 60X10-200:1, but the model only show the length of 0.0001

 

thx

 

Cean

 

 

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

Post to forums  

Autodesk Design & Make Report