Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C# API Occurences iProperties Projekt

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
christoph.steidle
319 Views, 4 Replies

C# API Occurences iProperties Projekt

christoph.steidle
Participant
Participant

Hello all,

I have been searching here in the forum for a long time but unfortunately have not yet found a solution.

Is there a way to access the iProperties/project via the API and query the values?

christophsteidle_0-1664891844491.png

 

I have the following code but I don't know which function I can use to query it.

Row 22 I try to search for it but it doesn'twork.

private static void GetOccurences(ComponentOccurrences componentOccurrences, int level, IProgressTracker tracker, CancellationToken token)
    {
        double count = 0;
        int numberOfAllObjects = componentOccurrences.Count;

        


        foreach (ComponentOccurrence occurence in componentOccurrences)
        {
            Functions.ProgressBar.CancelJob(tracker, token);

            //MassProperties
            var massProperties = occurence.MassProperties;

            //RefKey
            byte[] myRefKey = { };
            occurence.GetReferenceKey(ref myRefKey, _createKeyContext);
            listRefKeys.Add(_documentAssembly.ReferenceKeyManager.KeyToString(myRefKey)); //RefKEy kontrollieren

            //GetProperties
            var name = occurence.ItemByName["Description"];
}
}

 

Many thanks for your help.

Greetings
Chris

0 Likes

C# API Occurences iProperties Projekt

Hello all,

I have been searching here in the forum for a long time but unfortunately have not yet found a solution.

Is there a way to access the iProperties/project via the API and query the values?

christophsteidle_0-1664891844491.png

 

I have the following code but I don't know which function I can use to query it.

Row 22 I try to search for it but it doesn'twork.

private static void GetOccurences(ComponentOccurrences componentOccurrences, int level, IProgressTracker tracker, CancellationToken token)
    {
        double count = 0;
        int numberOfAllObjects = componentOccurrences.Count;

        


        foreach (ComponentOccurrence occurence in componentOccurrences)
        {
            Functions.ProgressBar.CancelJob(tracker, token);

            //MassProperties
            var massProperties = occurence.MassProperties;

            //RefKey
            byte[] myRefKey = { };
            occurence.GetReferenceKey(ref myRefKey, _createKeyContext);
            listRefKeys.Add(_documentAssembly.ReferenceKeyManager.KeyToString(myRefKey)); //RefKEy kontrollieren

            //GetProperties
            var name = occurence.ItemByName["Description"];
}
}

 

Many thanks for your help.

Greetings
Chris

4 REPLIES 4
Message 2 of 5

JelteDeJong
Mentor
Mentor
Accepted solution

Is this what you are looking for:

/*
AssemblyDocument document = (AssemblyDocument)ThisDoc.Document;
ComponentOccurrence componentOccurrences = document.ComponentDefinition.Occurrences[1];
*/
Document refDoc = (Document)componentOccurrences.Definition.Document;

// property (set) names can be found on:
// https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
PropertySet propertySet = refDoc.PropertySets["Design Tracking Properties"];
Property property = propertySet["Project"];
string project = property.Value as string;

System.Diagnostics.Debug.WriteLine(project);

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes

Is this what you are looking for:

/*
AssemblyDocument document = (AssemblyDocument)ThisDoc.Document;
ComponentOccurrence componentOccurrences = document.ComponentDefinition.Occurrences[1];
*/
Document refDoc = (Document)componentOccurrences.Definition.Document;

// property (set) names can be found on:
// https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
PropertySet propertySet = refDoc.PropertySets["Design Tracking Properties"];
Property property = propertySet["Project"];
string project = property.Value as string;

System.Diagnostics.Debug.WriteLine(project);

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 5

christoph.steidle
Participant
Participant

@JelteDeJong 

Thank you very much for your answer.

I have just tested it in the way you suggested.

In "property" I get the following values displayed.

 

christophsteidle_0-1665124557541.png

However, I would like to read out the designation (Beschreibung) as shown in the following picture.

christophsteidle_1-1665124607725.png

I hope it is clear what I mean by this. 🙂

Thank you very much for your help.

Greetings 
Chris

0 Likes

@JelteDeJong 

Thank you very much for your answer.

I have just tested it in the way you suggested.

In "property" I get the following values displayed.

 

christophsteidle_0-1665124557541.png

However, I would like to read out the designation (Beschreibung) as shown in the following picture.

christophsteidle_1-1665124607725.png

I hope it is clear what I mean by this. 🙂

Thank you very much for your help.

Greetings 
Chris

Message 4 of 5

JelteDeJong
Mentor
Mentor

Have a look at this article. 
https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html

at bottom you will find a table with the propery(set) names that you can use. 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes

Have a look at this article. 
https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html

at bottom you will find a table with the propery(set) names that you can use. 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 5

christoph.steidle
Participant
Participant

Thank you very much now it works! 🙂

0 Likes

Thank you very much now it works! 🙂

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

Post to forums  

Autodesk Design & Make Report