Using Dynamo to set work plane in 3D view

Hello,

I’m trying to use dynamo to set my work plane in a 3D view based off of a piece of conduit. The idea is to be able to select a piece of conduit, and have dynamo create/select of orthogonal work plane to it that I can use to place a dimension on.

I’ve been able to essentally just grab a point and create a XY, YZ, or ZX plane off of it, but I’m unsure if there’s a way to make dynamo then set it as a work plane.

This is what I have so far.

image

Hi @stewart.skyler,

The Set SketchPlane By Line node can maybe help you.
I use it to create dimensions in 3D view.

Set%20SketchPlane%20By%20Line

Here is an example :

1 Like

Thanks for the response.

This looks like it would work if I was trying to dimension from inside dynamo. But ideally I’d prefer to manually dimension my conduit runs, as I don’t quite want to take the time to figure out how to make dynamo select the right points for me to measure from the outsides of conduits.

My ideal outcome is to be able to select a piece of conduit, like the one shown below, click play in the player, and it would move that work plane to something orthogonal to it.

Some quick sloppy manual examples:


image

3 nodes only :

Oh okay, yeah that got me quite a bit closer. It did set the active sketch plane, but not in a helpful orientation.

My python abilities are pretty rough, but from looking at your code, I’m not quite sure what the difference is that let your code set the active sketch plane.

Could I possibly take your code, and augment it to draw a plane in essentially the way shown here?

Thanks again for all the help

Update to anyone who comes across this:

After doing more research for a while, and much fiddling around with my basic coding knowledge, this is the solution I found:


import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

# The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

# Unwrap elements and convert geometry from Dynamo to Revit:
bubbleEnd = [point.ToXyz() for point in IN[0]]
freeEnd = [point.ToXyz() for point in IN[1]]
thirdPnt = [point.ToXyz() for point in IN[2]]
pView = UnwrapElement(doc.ActiveView.ToDSType(True))

# Create the reference plane in a transaction
TransactionManager.Instance.EnsureInTransaction(doc)
rPlane = doc.Create.NewReferencePlane2(bubbleEnd[0],freeEnd[0],thirdPnt[0],pView)
TransactionManager.Instance.TransactionTaskDone()

# Set the reference plane as the sketchplane in the active view in another transaction
TransactionManager.Instance.EnsureInTransaction(doc)
sp = SketchPlane.Create(doc,rPlane.Id)
doc.ActiveView.SketchPlane = sp
TransactionManager.Instance.TransactionTaskDone()

OUT = rPlane

Of course, this doesn’t work in assembly views like I wanted. I believe this is because dynamo wants to draw a model line to create the reference plane, and you can’t add geometry in a assembly view without editing the assembly.
I think at that point I’m too far out of my depth, but hopefully this helps someone.

1 Like