Get Z-axis value or floor plan height

Hi guys/gals,

I have a model with plenty of levels and I am trying to place lines on the floor plan. I have everything worked out except for the Z-axis. I cannot figure out what my height is so I can place lines there.

I tried the level node to get the z-axis but the lines are always off. Either it being too high or too low. My main question is can I check the floor plans elevation value?

Hi Tainted,

I believe you should be able to get the associated level of the floor plan and then use the level elevation.
Although you may have to be aware of the elevation base of said level.
If it has been set to survey point, you may have to correct it accordingly.

Now you mention some “lines”, might be easier if we know more about the exact purpose.
However, using the “View range” of the floorplan to get the cut plane offset might be what you need? :slight_smile:

Although, as I mentioned, it would be a lot easier if we had more information.

Anyway, I hope it helps!

Welcome to the forum @Tainted

There is a situation here because you have not told us if you need detail lines or model lines.
Detail lines need a view, not a level and are only visible in the view you place em.
Model lines however need a level and are visisble in all views at that level.
So let me know.

Yes, I tried the level node then the level.elevation node to get a value. I use that value as the z-axis but as I mentioned the lines do not show up on the floor plan as they are either higher or lower than what the elevation nodes says. The problem seems to be that the floor plan elevation is at a different value.

I am just trying to make a small grid on the floor plan. I am adding lines x and y amount of space apart. The only issue I am having is finding the right z distance to place the lines. The lines are model lines if that helps

can you show us what you have?

Out of curiosity, are your project base point and survey point located at the internal origin?
Or have they been moved?

But as Marcel said, we would like to see what you have as it probably provides a lot more context.

Yes, not exactly sure what to show but this is what I got. Sorry I tried to clean it up but its really messy as I am still adding more stuff.

Idk if you can see it but I drew a red circle and you can see a blue dot there. Basically it will make a grid around that dot or intersection. The X and Y coordinates are correct.
The problem being the Z-axis. I tried getting it by selecting the level and then elevation but it seems like the floor plan is not at that elevation.

If I go in 3D, I can see the lines so I know they are being placed.

I think you need to create a dynamo curve (blue preview in Revit) and translate that into a revit curve.
use the node ModelCurve.ByCurve and maybe a sketch plane too. im working on it

I’m not quite understanding what you mean.

Maybe I should explain mine a little more?
The user selects an intersection based on the grids. Say A1 in this case then I put points X and Y distance apart around the intersection and finally place a basic line family on the points. Everything works fine except for the Z axis on where to place the lines.

If I could find a way to get the value or height of where the floor plan is then I should be okay. I gave the user options to set their level elevation but it doesn’t match the floor plan elevation.

Maybe I’m just doing wrong and your way might work better. I’ll just wait until you’re done.

Hi, Tainted,

Can you check if the following Python script returns another elevation than what you currently have?
Hopefully, it’s what you need or helps you get there.
However, it is a bit difficult to be sure without a test project.
Apologies for the lazy imports.

import clr
# Import assemblies and API methods
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
output = list()
from System.Reflection import Assembly
dynamo = Assembly.Load('DynamoCore')
import os
import datetime
import ctypes
clr.AddReference("RevitServices")
import RevitServices
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
doc = DocumentManager.Instance.CurrentDBDocument
# Custom Function definitions
def input2list(input):
	if isinstance(input,list):
		return UnwrapElement(input)
	else:
		return [UnwrapElement(input)]

def GetLevelElevation(doc,view):
	vr = view.GetViewRange()
	vroffset = vr.GetOffset(PlanViewPlane.CutPlane)
	vrElevation = view.GenLevel.ProjectElevation
	LevelElevation = vroffset+vrElevation
	return LevelElevation
  # Declare variables
  output = list()
  # Input
  input = input2list(IN[0])
  # Code to run
  for data in input:
  	# Convert elevation from internal units to mm
  	output.append(GetLevelElevation(doc,data)*304.8)
# Output
OUT = output
2 Likes

Sorry I am not familiar with Python Scripts or Revit API (I want to learn though).
Which node(s) do I connect to the python script?
I keep getting error stating attribute error: object has no attribute ‘getviewrange’

Hi Tainted,

Apologies, forgot to write that down.
Try to feed the “ActiveDocument” and “Document.ActiveView” to the python script node.
Or if you have a node to get the ActiveView in one go, you may as well go ahead and use that.
I don’t have access to Revit atm but can post a screenshot later if needed.

Sorry about late reply, I had a to figure this out today.

Here is what i got from your script.

I ended up with a solution. The node I needed was Level.ProjectElevation
That gave me the proper z axis or height that I needed. For some reason Level.Elevation is not the correct height and was not working.

However, I am having another different problem.
Basically, when I run this dynamo script on a level it works but when I go try to run it again on a different level the previous level lines get deleted. The lines don’t get saved, they just overwrite the previous ones. Can anyone explain why this is happening?

Also, is there anyway to hide the dynamo overlay? The blue tint/color that is being displayed when dynamo is ran.
Revit_3ZS18RNFYn

Are you creating any Revit Model Lines with your script?

When Dynamo overwrites my work, I have to remember to close my Dynamo window, save my Revit file, and then re-open Dynamo and run my script again.

There is a way to turn off the Dynamo overlay. Go to the top menu under View> Background 3D Preview > Available Previews > Revit Background Preview. Uncheck “Revit Background Preview”

Yes, I am creating Revit Model Lines.

The way I ended up getting this to work was to copy all the nodes (Ctrl + A, Ctrl + C) then creating a new graph and pasting the nodes then running it again.

Note I only had to do this for Revit 2016 as that one has no Dynamo player. For 2017 and above I just end up using the player.