Inventor 2020 iLogic add Content Center Part by Custom Field

Inventor 2020 iLogic add Content Center Part by Custom Field

tmuel
Advocate Advocate
3,310 Views
11 Replies
Message 1 of 12

Inventor 2020 iLogic add Content Center Part by Custom Field

tmuel
Advocate
Advocate

Hello,

 

I am working on some utilities that make use of the new iLogic add.ContentCenterPart functionality for Inventor 2019 and 2020 prior to upgrading out engineering group. First, I'd like to say well done to the Dev team. I spent some time attempting this connection before it was supported, and it was never reliable enough for production use. This is working quite well for me - with the following exception: 

 

I ran into an issue that I hope has a simple solution (besides fixing our CC databases). I will be the first to admit the limitation is due to our own inconsistent CC standards. We have Custom Content libraries that were created some time ago by different people and they are very inconsistent with regard to the formatting of properties. The thing about them that is consistent is that they all have unique custom "Part_Number" column, but they DO NOT all have unique "Designation" fields. 

 

The Components.AddContentCenterPart function uses the CCpath, ccFamilyName, Designation to define the part that is being added/modified. Because our "Designation" field may be non-unique, this causes unexpected results. 

 

Is there a way to specify the CC Member using a different property than "Designation"? A custom property would be ideal for us, but the member coulumn or FileName would suffice.

 

Please see the image:

BoltDesignation.png

Thanks for any input.

 

Tim

0 Likes
Accepted solutions (1)
3,311 Views
11 Replies
Replies (11)
Message 2 of 12

MjDeck
Autodesk
Autodesk
Accepted solution

Yes, this is possible. There's another AddContentCenterPart function that accepts one or more pairs of {"ColumnName", "Value"} instead of a Designation. Here's some sample code:

Dim hex2 = Components.AddContentCenterPart("Hex:2",
"Fasteners:Bolts:Hex Head",
"BS EN 24014 - Metric",
{"FILENAME", "ISO 4014 - M3.5 x 20BS EN"},
ThisAssembly.Geometry.Point(0, 0, 0))

Dim hex3 = Components.AddContentCenterPart("Hex:3",
"Fasteners:Bolts:Hex Head",
"BS 3692 Precision hexagon bolts and screws (Full Threaded) - Metric",
{"PARTNUMBER", "BS 3692 - M2 x 6(1)"},
ThisAssembly.Geometry.Point(0, 0, 2))

Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 12

tmuel
Advocate
Advocate

Mike,

 

This is fantastic! It works exactly as I hoped. This will save me a lot of time and unnecessary assembly updates to legacy data. Thank you very much!

 

A side note for anyone that would like to use the FILENAME property. If the Content Center database has illegal characters in the FILENAME property, the name is changed automatically to an acceptable one when the content is generated.

 

Make sure to use the FILENAME property as specified in the CC database, not in the actual file.

 

For example:
Actual filename fails:
"CAP SCREW HH 1_2-13 x 3 1_2 LG"

 

Content Center DB FILENAME works perfectly:
"CAP SCREW HH 1/2-13 x 3 1/2 LG"

 

Thanks again Mike!

 

Tim

0 Likes
Message 4 of 12

FrankHermens4Y53K
Contributor
Contributor

Hello @MjDeck ,

 

I hope you can help me with this. I cant get my code to work in a external rule. I am using the same sample code as you are and it is not working. The error i get when i run de code is this:

 

FrankHermens4Y53K_0-1664782060658.png

(the more info tab is in the attachments)

 

it seems like it cant find "M10" but if i run the exact same code in a normal rule (not external) then it runs just fine. So that means i dit not make a spelling error. I have no idea what i am doing wrong. can you (or some one else) help me with this?

 

Dim Vector1 = ThisDoc.Geometry.Vector(1, 0, 0)
Dim Vector2 = ThisDoc.Geometry.Vector(0, 1, 0)
Dim Vector3 = ThisDoc.Geometry.Vector(0, 0, 1)

'bolt 1
Dim Point_bolt_1 = ThisDoc.Geometry.Point(0, 0, 0)
Dim Matrix_bolt_1 = ThisDoc.Geometry.Matrix
Call Matrix_bolt_1.SetCoordinateSystem(Point_bolt_1, Vector2, Vector1, Vector3)

Dim Bolt_1 = Components.AddContentCenterPart("M10x100", "Fasteners:Bolts:Hex Head", "Bout th.vz. ISO passend 8.8", {"SIZE_SEL", "M10", "NLG", "100" },
position := Matrix_bolt_1, grounded := True, visible := True)

 

thanks in advance,

Frank

0 Likes
Message 5 of 12

MjDeck
Autodesk
Autodesk

@FrankHermens4Y53K , it sounds like you have to add code to explicitly set the Content Center language. That is used for the path ("Fasteners:Bolts:Hex Head" in this case). Please try adding this line to the top of your rule:

 

 

Components.ContentCenterLanguage = "en-US"

 

 

This is documented here


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 6 of 12

FrankHermens4Y53K
Contributor
Contributor

@MjDeck, thank you very much, that was ideed the problem. no wonder i could not find the problem, i had no idea this was a thing. 

0 Likes
Message 7 of 12

Maxim-CADman77
Advisor
Advisor

Dear @MjDeck 

Could you, please, clarify how to prevent crashing the rule with error on attempt to run it on wrong DocumentType after adding this line?

 

My code is:

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject
	logger.info("non-Assy")

Else
	Components.ContentCenterLanguage = "en-US" ' ???
	logger.info("Assy")
End If

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 8 of 12

MjDeck
Autodesk
Autodesk

Hi @Maxim-CADman77 , you can avoid the error by explicitly specifying ThisAssembly.Components:

ThisAssembly.Components.ContentCenterLanguage = "en-US"

If that doesn't work for you, please let me know which version of Inventor you're running.

Thanks for pointing out this problem. We should be able to fix it soon. 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 9 of 12

Maxim-CADman77
Advisor
Advisor

Adding "ThisAssembly." solved the issue (AI 2023.3).
Thank you very much!

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 10 of 12

Maxim-CADman77
Advisor
Advisor

DEar @MjDeck 

I would also like to know whether it is possible to determine current value of ContenCenterLanguage (the best practice of creating own app is not to force-change user settings but rather respect it, right?).

 

When I try to read the value like this:

logger.info(ThisAssembly.Components.ContentCenterLanguage)

... I just get an empty value.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 11 of 12

Maxim-CADman77
Advisor
Advisor

@MjDeck ,
 Sorry for asking new question before an answer for the previous but:

I'd also like to know how do I insert CCL-component (let say tube) with custom length value.
When I try to call AddContentCenterPart with designation containing modified value which is not present in the family table I then get
"AddContentCenterPart: No content center row with the specification <modified designation> was found. ..." error.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 12 of 12

MjDeck
Autodesk
Autodesk

Hi Maxim,

 The ContentCenterLanguage property is described here
People usually create Content Center rules within assembly documents. Those rules can potentially run on another user's computer, where the active CC language is different. For that reason, the original CC language is stored as an attribute in the document. 

 It's difficult to write code to add CC parts, and have it work in any language. This is because the path and family names are localized. Here's an example in French:

Dim Fond_plat_N_605_3_16 = Components.AddContentCenterPart("Fond plat N° 605. 3/16 x 5/8:1",
                                                           "Pièces d'arbre:Clavettes:Clavettes - Disque",
                                                           "Fond plat",
                                                           "N° 605. 3/16 x 5/8")

 

There is no function to add a custom part in Inventor 2023. But Inventor 2024 has the new function AddCustomContentCenterPart .

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes