dimven / NavisPythonShell

An IronPython console for Navisworks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ClashTest Constructor

ambrogomez opened this issue · comments

Hi there,

ClashTest Constructor
Create a clash test.
Namespace: Autodesk.Navisworks.Api.Clash
Assembly: Autodesk.Navisworks.Clash (in Autodesk.Navisworks.Clash.dll)

I think it should be as simple as:

newclash = ClashTest()

For some reason I cannot figure out it does not work in PythonShell.
Any thought or advice?

Thank you very much in advance.

Note: I can do a workaround by duplicating a current ClashTest and do anything from there, but I would prefer if I can use the ClashTest constructor.

Hi,

Did you reference the correct dll and import its namespace first? (Autodesk.Navisworks.Clash.dll)

Hi there,

Hmmm being honest I am not totally sure. I think I referenced the correct dll although.

In term of importing. I have not imported it. May I ask how to import it? Although if I have access to copyclash, testData, test, and others... it made me think it was imported.

Let me know your advice please.

Thanks

Hi,

Did you regerence the correct dll and import its namespace first? (Autodesk.Navisworks.Clash.dll)

Hi there,

Thank you for the previous answer.

I am just trying to import the namespace but I am not having any luck. Try in different ways, as it may be the case I am not writing correctly...
Examples tried:

>>> from Autodesk.Navisworks.Api.Clash import * Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named Clash

>>> from Autodesk.Navisworks.Clash import * Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named Clash

I have seen the assembly: Assembly: Autodesk.Navisworks.Clash (in Autodesk.Navisworks.Clash.dll) was not in the Assemblies folder when I download from the website. Is it the issue?

Thank you very much. I am not good compiling... if you have any website/tutorial or any location where I can read and learn further it will be great.

Thanks again.

Solution below:

import Common Language Runtime

import clr

import crutial information about the Python Script

import sys

append the dir where reference/assemblies live in Navisowrk

sys.path.append(r'C:\Program Files\Autodesk\Navisworks Manage 2018\Autodesk.Navisworks')

add many reference as you wish from Navis folder, in the case below Timeliner and Clash

clr.AddReference('Autodesk.Navisworks.Timeliner.dll')
clr.AddReference('Autodesk.Navisworks.Clash.dll')

import the reference to be used, in the case below (Clash & Timelines)

from Autodesk.Navisworks.Api.Clash import*
from Autodesk.Navisworks.Api.Timeliner import*

Thanks

Glad you figured it out!

You can make it a bit more version agnostic like so:

navisDir = doc.GetType().Assembly.Location.rsplit("\\", 1)[0]

import sys
sys.path.append(navisDir)

import clr
clr.AddReference("Autodesk.Navisworks.Clash")
from Autodesk.Navisworks.Api.Clash import ClashTest

#test the creation
ct = ClashTest()
print ct

Glad you figured it out!

You can make it a bit more version agnostic like so:

navisDir = doc.GetType().Assembly.Location.rsplit("\\", 1)[0]

import sys
sys.path.append(navisDir)

import clr
clr.AddReference("Autodesk.Navisworks.Clash")
from Autodesk.Navisworks.Api.Clash import ClashTest

#test the creation
ct = ClashTest()
print ct

Hi,

Does this works within the NavisPythonShell plug-in of Navisworks?
Or also in Dynamo Sandbox?

Thanks.