Move and Rotate grids with reference to first intersecting grid point

Hi all

I want to move all the grids from one point to another point (taking reference as: First grid intersection point) That means I want move whole grids from first intersection point to the origin. and then I want to rotate all grids with respect to moved point(first grid intersection point) by an angle

Please let me know. Is there any way to do that ?

It appears that you are referring g to the survey point or project base point not the origin, but this should allow you to shift the grids: Dynamo Dictionary

To move it to the origin, first find the intersection point between the two grids. Then convert that point to a vector (Point.AsVector), reverse that vector, and use the Element.MoveByVector node to shift things into place.

To put the grids into any other location you would want to find the vector from the current intersection point to the desired location point (Vector.ByTwoPoints), and use that to move the list of grids.

3 Likes

Hello…probably something could help…

1 Like

Hi @sovitek & @jacob.small Thanks for your response. But I am getting this error.

I have found the first grid intersection point and the origin(it may be survey point or project base point) and then as you said I have converted that point as vector and reversed it and when I try to move it I have got the error

Hi it looks like you will move to your PB point as not the origin in your cace…

something should work…

move grid.dyn
(14.2 KB)

probably you will need a vector reverse after vector by 2 points…

1 Like

@sovitek I have used that but still the same error

can you show your whole graph with preview expanded…it insnt what i show

@sovitek I have tried it with both ways. by vector by two points (origin and first intersection point) and other method. For both I am getting the same error

could you share your graph ?

1 Like

Here it is I want to move to a point and then I want to rotate all grids by an angle with respect to the moved point(First intersecting point) please have a look and please let me know

Non uniform grids spacing.xlsx (8.3 KB)

Parametric Grids creation.dyn (229.1 KB)

@jacob.small @sovitek Should I use python to move and rotate ? if so Can anyone please help me out with this ?

@jacob.small @sovitek I am trying with python but it is not working

I have tried with this. I want to move the grids to particular point and rotate with respect to that point by an angle. Please let me know where I am missing. I am not getting any errors but I am not finding any changes after run.

import clr
# Import RevitAPI Classes
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import math

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

elements = UnwrapElement(IN[0]) if isinstance(IN[0],list) else [UnwrapElement(IN[0])]
locations = IN[1] if isinstance(IN[1],list) else [IN[1]]
angles = [i* math.pi/180 for i in IN[1]] if isinstance(IN[2],list) else [IN[2]* math.pi/180]

def GetCropBox(view):
	provider= ParameterValueProvider(ElementId(BuiltInParameter.ID_PARAM))
	rule = FilterElementIdRule(provider, FilterNumericEquals(), view.Id )
	filter= ElementParameterFilter(rule)
	return doc.GetElement(FilteredElementCollector(view.Document).WherePasses(filter).ToElementIds().Find(lambda x: x.IntegerValue != view.Id.IntegerValue))
	
TransactionManager.Instance.EnsureInTransaction(doc)
for element,location,angle in zip(angles,elements,locations):
	#Move grids to the location
	if hasattr(element, "Location"):
		loc = element.Location
		if loc:
			if isinstance(element,Autodesk.Revit.DB.Grid):
				loca=element.Curve.Evaluate(0.5,True)
			else :
				box = element.get_BoundingBox(None)
				loca = (box.Min+box.Max)/2
			ElementTransformUtils.MoveElement(doc,element.Id,location.ToRevitType()-loca)
	elif hasattr(element, "OwnerViewId"):
		view=element.Document.GetElement(element.OwnerViewId)
		box = element.BoundingBox[view]
		loca = (box.Min+box.Max)/2
		ElementTransformUtils.MoveElement(doc,element.Id,location.ToRevitType()-loca)
	elif isinstance(element,Leader):
		element.End=location.ToXyz()
		#Rotation of grids
		if loc:
			if isinstance(element,Grid):
				line=element.Curve
				start=line.GetEndPoint(0)
				end=line.GetEndPoint(1)   
				box=BoundingBoxXYZ()
				box.Min = start
				box.Max = end
				loca = (box.Min+box.Max)/2
				rot = 0
			else:
				box = element.get_BoundingBox(None)
				loca = (box.Min+box.Max)/2
				rot = 0
				
	Autodesk.Revit.DB.ElementTransformUtils.RotateElement(doc, element.Id, line, angle-rot)
				
TransactionManager.Instance.TransactionTaskDone()

if isinstance(IN[0], list): OUT = elements
else: OUT = elements[0]

You’re close in the use of the element transform utilities, which is how the Element.MoveByVector node works. You don’t need for those ‘if’ statements though - all grids have a location so asking if they have one isn’t needed.

Also ElementTransformUtils has a great means of moving everything at once in the MoveElements method, same thing for rotate in the RotateElements method.

This is how I’d work this out:
image

Note that you need to create a .Net list (imported as cList in my code) which has a good many uses in the API. Also the angle needs to be in radians, not degrees. The grid name(s) used for filtering for the intersection point is currently “1” and “A” - you might want to use something else.

Move_and_rotate_elements.dyn (42.5 KB)

1 Like

Thank you so much @jacob.small It helps in some of my cases. I really appreciate that you gave time for this.

1 Like