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

Navisworks API with Javascript documentation

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
dimonik
1858 Views, 9 Replies

Navisworks API with Javascript documentation

Hello!

 

Is there any documentation about javascript methods that work with NavisWorks API?

9 REPLIES 9
Message 2 of 10
IanBadcoe
in reply to: dimonik

There are no built-in Javascript APIs for Navisworks, however tools exist that should enable you to access the product's .NET or COM APIs.

 

There may be security limitation that you need to overcome to permit your Javascript environment to call into an installed program.

 

Ian

Message 3 of 10
dimonik
in reply to: IanBadcoe

Could you help me with these tools?

 

I read post in AEC DevBlog (http://adndevblog.typepad.com/aec/2012/05/search-compnents-in-javascript.html) and want to make search function,

but in our nwd file there is no entity handle parameter for components in Navisworks. There are only Id and GUID parameters (see on screenshot).

Can I find using these parameters?

Message 4 of 10
IanBadcoe
in reply to: dimonik

Hi,

 

ADN are your general source for API help.

 

I cannot help you with those tools as I am not an Javascript developer, however a quick web-search revealed several prossibilities.

 

Whether you can search on those or not depends entirely on what you are attempting to achieve.  If you have a GUID/Id and want to find the corresponding entity then obviously searching by GUID will be useful.  If that isn't what you are trying to do then it wouldn't help.

 

The questions are:

- what do you want to search for?

- what do you want to search by?

 

Given the answers to those, it should be pretty obvious whether you have what you need.

 

Ian

Message 5 of 10
dimonik
in reply to: IanBadcoe

Ian,

 

i want to search components by GUID, because in our nwd file components don't have entity handle parameter. So i need little bit modify function from blog, but i don't know how GUID called. From example i see that entity handle called "LcOpDwgEntityAttrib", Revit Id called "LcRevitId".

 

If i'm not a member of ADN, how can i ask them questions?

Message 6 of 10
IanBadcoe
in reply to: dimonik

Hi

 

You have to join ADN to get full API support.

 

However, to find the internal name of a property do the following:

 

Goto global options.

Goto Interface -> Developer

Check the "Show Property Internal Names" box

 

Navisworks will now display internal property names in the propterties window.

 

Ian

Message 7 of 10
xiaodong_liang
in reply to: dimonik

Hi dimonik,

The first argument of SetPropertyNames or SetAttributeNames is the internal name of the property/attribute, while the second argument is the user name, typically they are what the end user can see in the properties panel. Not all properties/attributes have the given name as LcRevitId/LcOaNat64AttributeValue. you could ignore leave the first argument as empty, e.g.

findcon.SetPropertyNames("", "your_property_display_name");
findcon.SetAttributeNames("","your_attribute_display_name");

But, I do suggest you firstly dump the attributes & properties of the model to check if Navisworks have given a specific internal name for them. The SDK sample api\COM\examples\ActiveX\ActiveXDumpStructureExample can be used to dump.

 

If none of them can work, please attach a demo model file. I can take a look.

A non-ADN can post questions on forum. Our team (Developer Technical Services) and engineer team frequently help the questions here, though it may be not quicker than ADN members. Thanks for your understanding!

Message 8 of 10
dimonik
in reply to: xiaodong_liang

Hi, Xiaodong.

 

I use internal properties and attribute names:

 

findcon.SetPropertyNames("LcOaNode");
findcon.SetAttributeNames("LcOaNodeGuid");
findcon.Condition = state.GetEnum("eFind_EQUAL");
findcon.value = "2f50997e-7f04-4fb8-b221-8379d5f18b95";

but script doesn't zoom to element.


I've attach a piece of our model. Please, take a look.

Our task is to highlight the item and zoom to it.

Message 9 of 10
xiaodong_liang
in reply to: dimonik

Hi,

 

as mentioned, the first argument of the two methods are the internal name.  I do not know how you found they are:

 

LcOaNode

LcOaNodeGuid

 

When I dumped the attributes and properties, they are:

 

Attribute:

Internal Name:  "NOT AN ASCII STRING"      

Display Name:   “DWF - Стол-Прямоугольный [766585]”

 

Property:

Internal Name:  " LcDwfData"

Display Name:   “Guid”

 

 

Attribute’s Internal Name is because it should be ASCII string, while the Russian characters are not identified. But  the internal name can be ignored. With the following JS code, it is working well.

 

Hope it helps.

 

<script type="text/javascript">
 
function zoomToObj() {
 
//  find item with entity handle '127587'
    var state = NWControl01.state;
    var find =
        state.ObjectFactory(
            state.GetEnum("eObjectType_nwOpFind"));
    var findspec =
        state.ObjectFactory(
            state.GetEnum("eObjectType_nwOpFindSpec"));
    var findcon =
        state.ObjectFactory(
            state.GetEnum("eObjectType_nwOpFindCondition"));
 
// set condition
 
    //findcon.SetPropertyNames("LcOaNat64AttributeValue");
    //findcon.SetAttributeNames("LcOpDwgEntityAttrib");
    //findcon.SetAttributeNames("LcRevitId");
    findcon.SetAttributeNames("", "DWF - Стол-Прямоугольный [766585]");
    findcon.SetPropertyNames("","Guid");
    findcon.value = "2f50997e-7f04-4fb8-b221-8379d5f18b9b";
    //or
    //findcon.SetPropertyNames("","Id");
    //findcon.value = "766585";
    findcon.Condition = state.GetEnum("eFind_EQUAL");
    
 
// do find
    findspec.Selection.SelectAll();
    findspec.Conditions().add(findcon);
    find.FindSpec = findspec;
    var sel = find.FindAll();

    alert(sel.Paths().Count);
 
// highlight the items and zoom to them
    state.CurrentSelection = sel;
    state.ZoomInCurViewOnCurSel();
}
</script> 

 

Message 10 of 10
dimonik
in reply to: xiaodong_liang

Thanks, it helped.

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

Post to forums  

Rail Community


Autodesk Design & Make Report