Launch lineworks tool in Dynamo.

Launch lineworks tool in Dynamo.

MVE1112
Advocate Advocate
2,239 Views
6 Replies
Message 1 of 7

Launch lineworks tool in Dynamo.

MVE1112
Advocate
Advocate

Hello all,

 

I am arriving at this board as somewhat of a last resort..

I have searched far and wide for a way to use the linework tool in Dynamo on all lines in an active view to no avail.

 

Now i am left wondering if it would even be possible to make Dynamo launch the Linework command via a C++ node.

 

I looked in the revit API library and i can see that Linework is a postable command member but i am afraid this is far beyond my level of skill..

 

Is there anyone here who could help me out?

The end goal is to make Dynamo launch the linework tool and then selecting all lines in view and setting them to invisible. I believe i can manage that last part as long as i can get lineworks to work in Dynamo..

 

Any help is greatly appreciated!

0 Likes
2,240 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk

You can use the .NET Revit API call PostCommand to launch postable commands:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.3

 

However, it just launches the standard built-in end user Revit command including its standard user interface.

 

Hence you will need to handle the second part of the task that you mention, selecting all lines in view and setting them to invisible, manually, just as you would in the normal Revit command.

 

Is that what you are after?

 

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 7

MVE1112
Advocate
Advocate

Hey, thanks for your reply, that is exactly what i am looking for.

 

I found this python script online to call another command, when i entered linework as the command to look up it didnt work.

Im afraid my programming skills are next to nothing..

 

Would you care to take a quick gander at it? If not i am happy to accept your original awnser as the solution since you did answer my question.

 

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
import Autodesk
from Autodesk.Revit.UI import RevitCommandId
from Autodesk.Revit.UI import UIApplication
from Autodesk.Revit.UI import ExternalCommandData
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

uiapp = DocumentManager.Instance.CurrentUIApplication

RunIt = IN[0]

if RunIt ==  True:
    CmndID = RevitCommandId.LookupCommandId('Linework')
    CmndId = CmndID.Id
    uiapp.PostCommand(CmndID)
    errorReport = 'Success'
else:
    errorReport = 'Set IN[0] to true'

#Assign your output to the OUT variable
OUT = errorReport 

 

 

 

Below the errormessage i receive..

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File "<string>", line 18, in <module>
AttributeError: 'NoneType' object has no attribute 'Id'

0 Likes
Message 4 of 7

jeremytammik
Autodesk
Autodesk

The error message "AttributeError: 'NoneType' object has no attribute 'Id'" is presumably caused by the line "CmndId = CmndID.Id". What it probably means is that CmndID is a 'NoneType' object and therefore contains no data at all. That in turn means that your call to LookupCommandId did not work. I very much doubt that 'Linework' is the correct string to use for the lookup. In general, the command id strings are more complicated. Try passing in an emumeration value instead, e.g.:

 

  CmndID = RevitCommandId.LookupCommandId( PostableCommand.Linework )

 

For examples, please refer to The Building Coder topic group:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.3

 

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 7

lionel.kai
Advisor
Advisor

I posted an Idea for this requested functionality here:

 

API access to Linework tool (get and set edge/line overrides) - Autodesk Community


Lionel J. Camara
BIM Manager at KAI Hawaii, Inc. - Structural and Forensic Engineers
Autodesk Certified Professional
0 Likes
Message 6 of 7

ctm_mka
Collaborator
Collaborator

Two things, first, since you are looking to "postcommand" the Linework tool, you need to lookup the "postablecommandid" instead,

 

CmndID = RevitCommandId.LookupPostableCommandId(PostableCommand.Linework);

 

Second, since "postcommand" is asynchronous, and as Jeremy stated, you'd end up manually changing all the lines anyways. Have you tried setting graphical overrides? Either as nodes in Dynamo or as code would do the trick and keep your initial selection set.

0 Likes
Message 7 of 7

ctm_mka
Collaborator
Collaborator

Also, what elements are you looking to turn invisible? You cant use the Linework tool on detail elements (detail lines, detail components, etc.) You can, however turn off the visibility of detail elements, but then how would you find them to turn them on? Or you could turn the white if you were going to print.

0 Likes