dimven / NavisPythonShell

An IronPython console for Navisworks
MIT License
69 stars 14 forks source link

ClashTest Constructor #7

Closed ambrogomez closed 4 years ago

ambrogomez commented 4 years ago

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.

dimven commented 4 years ago

Hi,

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

ambrogomez commented 4 years ago

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

ambrogomez commented 4 years ago

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

dimven commented 4 years ago

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
ambrogomez commented 4 years ago

Thank you mate.

Appreciate it :)

On Tue, 17 Sep 2019, 08:39 Dimitar Venkov, notifications@github.com wrote:

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

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dimven/NavisPythonShell/issues/7?email_source=notifications&email_token=ALR2RPAWCDUWIMRGNDT67FTQKCCS7A5CNFSM4IXB5RK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD63TSXQ#issuecomment-532101470, or mute the thread https://github.com/notifications/unsubscribe-auth/ALR2RPFUQKXYFJYNZ3RNA73QKCCS7ANCNFSM4IXB5RKQ .

EdwardWinter commented 1 year ago

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.