How to read custom properties from navisworks file.

How to read custom properties from navisworks file.

Anonymous
Not applicable
7,384 Views
41 Replies
Message 1 of 42

How to read custom properties from navisworks file.

Anonymous
Not applicable

Hi.

 

User is adding additional properties (custom properties) using Navisworks Data Tools. When i am reading the properties from navisworks file using the API's, the API is returning all the properties under "Item", "Material", "Timeliner", "Entity Handle", "Autoplant Component", "Autocad" tabs. But this navisworks file has one more property node called "XYZ"(example, this is user defined name) and this property node has multiple properties user has entered. But the API is not reading these properties. So, the question is how to read Custom or user defined properties from navisworks file?

 

Here is the piece of code to read the properties i have in my project. 

GetValue(oModelItem, null)).GetEnumerator();

while (ePropertyCatIterator.MoveNext())
{
object oPropCatIter = ePropertyCatIterator.Current;
string sCategory = Convert.ToString(oPropCatIter.GetType().GetProperty("DisplayName").GetValue(oPropCatIter, null));


IEnumerator<Object> ePropertyIterator = ((IEnumerable<Object>)oPropCatIter.GetType().GetProperty("Properties").
GetValue(oPropCatIter, null)).GetEnumerator();

      while (ePropertyIterator.MoveNext())
      {
                  object oPropIter = ePropertyIterator.Current;
                  string sValue = Convert.ToString(oPropIter.GetType().GetProperty("Value").GetValue(oPropIter, null));
                   string sName = Convert.ToString(oPropIter.GetType().GetProperty("DisplayName").GetValue(oPropIter,        null));

     }

}

Regards

Sampath

7,385 Views
41 Replies
Replies (41)
Message 21 of 42

ulski1
Collaborator
Collaborator

hi,

One possible reason it doesn't work for you is that the nwd file was published with the "Prevent Object Property Export" enabled See image.

Publish_dialog.jpg

 

0 Likes
Message 22 of 42

sampath.jeedigam
Enthusiast
Enthusiast

Its uncheck only. 

0 Likes
Message 23 of 42

ulski1
Collaborator
Collaborator

I tested the code in Navisworks Simulate 2021 - perhaps if you use an older version that could be the reason - that I don't know - I don't work for Autodesk

0 Likes
Message 24 of 42

sampath.jeedigam
Enthusiast
Enthusiast

Ok. Thanks..

 

 

 

0 Likes
Message 25 of 42

xiaodong_liang
Autodesk Support
Autodesk Support

@sampath.jeedigam , @Anonymous , my apology for the late jumping into. 

 

I did a test with DataTool (Excel) and AppInfo plugin, I also tried with CodeRun with the code of @ulski1 , it looks it can be found by display name. Note: display name is language sensitive, while it looks you are in English environment, it should be fine with English words(same to what are seen in UI).  Navivsworks version 2020, Excel is 16.0 (64bits)

 

even if FindbyDisplayName cannot work, could you try with FindbyName or FindByCombinedName?  If none of them work, we will need to have your demo models and excel file to diagnose. 

 

special thanks @ulski1 for the inputing and helping!

 

 

Screen Shot 2021-01-15 at 3.15.46 PM.png

Screen Shot 2021-01-15 at 2.41.19 PM.pngScreen Shot 2021-01-15 at 2.39.37 PM.pngScreen Shot 2021-01-15 at 2.41.06 PM.png

0 Likes
Message 26 of 42

sampath.jeedigam
Enthusiast
Enthusiast

Thank you @xiaodong_liang  for responding my query. As mentioned above i tried by calling the FindByDisplayName and FindByName functions but did not get those properties. In one of the messages, @ulski1  mentioned below comments. 

 

"this means the data comes in via a link to a database (or other odbc source). The code suggestions you have been given is for the user data LcOaPropOverrideCat type attribute data so that is perhaps why things are not working"

 

I will share the excel and dataset soon. We are using Navisworks Simulate 2018.


Regards
Sampath.

0 Likes
Message 27 of 42

ulski1
Collaborator
Collaborator

one wild guess is that you haven't enabled "Hold open for application lifetime" in the datalink definition dialog.

 

br

Ulrik

0 Likes
Message 28 of 42

xiaodong_liang
Autodesk Support
Autodesk Support

@ulski1 I did not check that option when testing. Even if lifetime affects, it would only affect the linked properties are shown up in panel or not. but obviously, in this case, it has been linked, though in cache until it is published to NWD... I'd wait for @sampath.jeedigam 's demo model and excel to reproduce. 

 

 @sampath.jeedigam  in the same time, will it be convenient to you to try with Navisworks 2020 at your side? It may not be related, but just in case 2018 has issue..

0 Likes
Message 29 of 42

ulski1
Collaborator
Collaborator

you haven't upgraded to 2021 yet?

0 Likes
Message 30 of 42

sampath.jeedigam
Enthusiast
Enthusiast

No. We are still using 2018 Simulate. Upgrading to 2021 will solve the problem?

0 Likes
Message 31 of 42

sampath.jeedigam
Enthusiast
Enthusiast

Hi @xiaodong_liang . Hope you are doing good.

 

Sorry for the big delay in providing the dataset and DB file to you. It took some time in getting the approvals from our customer to share the dataset with you. 

 

Is it possible for you to share Autodesk FTP to share the dataset as this is a customer dataset and this is a public forum?

 

Regards

Sampath

0 Likes
Message 32 of 42

ulski1
Collaborator
Collaborator
Most likely not, I was just teasing Xiaodong because he was mentioning 2020. Also since this post 2022 has come out.
0 Likes
Message 33 of 42

sampath.jeedigam
Enthusiast
Enthusiast

Ok. I am waiting for @xiaodong_liang to respond on the FTP path to share the dataset. Lets see whether he can verify the my dataset and confirm anything.

 

Regards

Sampath.

0 Likes
Message 34 of 42

sampath.jeedigam
Enthusiast
Enthusiast

Hi

 

@xiaodong_liang 

Any update on how to share the dataset ?

 

Regards

Sampath

0 Likes
Message 35 of 42

xiaodong_liang
Autodesk Support
Autodesk Support

Hi @sampath.jeedigam , @Anonymous ,

Sorry for my late response. you could upload the dataset to a shared storage, and send me the download link in private message. In addition, I forgot the context, have you tested with simple excel file + model ? 

0 Likes
Message 36 of 42

xiaodong_liang
Autodesk Support
Autodesk Support
Hi @ulski1 , sorry I also missed you were asking me..  My focus now is mainly Forge, so sometimes did not upgrade to new release of Navisworks soon. And actually I have also remote machine with release 2021 at that moment, but I was thinking it should work generally, so simply tried with 2020 at my local parallel machine  Now I am using 2022 on my local parallel machine 🙂
0 Likes
Message 37 of 42

sampath.jeedigam
Enthusiast
Enthusiast

Hi @xiaodong_liang 

 

I shared the files in google drive and sent you the link in a private message. Please confirm after you receive it. We worked on customer file only and dint tried with any sample excel. 

 

Regards
Sampath.

0 Likes
Message 38 of 42

sampath.jeedigam
Enthusiast
Enthusiast

@xiaodong_liang 

 

Did you get a chance to look into those files?

0 Likes
Message 39 of 42

xiaodong_liang
Autodesk Support
Autodesk Support

@sampath.jeedigam , I seemed not to see any private message from you recently. I am not sure what happened with forum mail.  The mails from other customers work well. Could you send me again? I am sending you one private message firstly, please try to reply from that

0 Likes
Message 40 of 42

sampath.jeedigam
Enthusiast
Enthusiast

@xiaodong_liang  I have sent you another message. Did you receive the files?

 

Regards

Sampath.

0 Likes