Split wall

Split wall

BenoitE&A
Collaborator Collaborator
9,737 Views
20 Replies
Message 1 of 21

Split wall

BenoitE&A
Collaborator
Collaborator

Hey,

I want to split a wall in 2 at a given point of its LocationCurve that I can compute. Then I will delete one of the 2 parts which is useless.

I could use the PostCommand corresponding to the UI (SplitFace) but it requires the user to do manually the cut while I compute automatically the position of the cut, which is more precise and easier.

Any idea?

Use InstanceVoidCutUtils? 

Benoit


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes
Accepted solutions (2)
9,738 Views
20 Replies
Replies (20)
Message 21 of 21

jeremy_tammik
Alumni
Alumni

Some new feedback on this topic after discussion with the development team -- many thanks to Jacob Small for this!

    

It appears that both of the 'issues' noted in relation to the work-around above are not valid. To confirm, these are:

    

  • if splitted walls are also rooms' boundaries, rooms get messed up
  • if splitted walls contain nested family instances like doors or windows, as you cannot rehost them to the correct wall, you have to recreate them, copy their parameter values, (with the inconvenience that they do not have the same Revit Id anymore), and delete the originals...

     

Regarding the first, rooms only get messed up if the 'gap' is over the room separation tolerance, which I think is 1 native unit.

  
Regarding the second, if the new wall is created before moving the old elements will host to the new wall if they fall on its extent.

   

Here is a Python solution that may help. On further review it does appear as if the hosted door is 'replaced' instead of relocated, so instance parameters which automatically update (e.g., mark) would need to be adjusted to the previous value, and element history will be lost -- an expected result of advanced model modifications:

   

### Configure the Python environment ###
import sys #add the sys class to the Python environment so we can work with the sys objects
import clr #add the CLR (common language runtime) class to the Python environment so we can work with .net libraries
 clr.AddReference("RevitNodes") #add Dynamo's Revit nodes library to the clr
import Revit #import Dynamo's Revit node class
 clr.ImportExtensions(Revit.Elements) #add the element conversion methods to the CLR
 clr.AddReference("RevitServices") #add the Revit services library to the CLR
import RevitServices #import the Revit services class to the Python environment
from RevitServices.Persistence import DocumentManager #import the documet manager class to the Python environment 
from RevitServices.Transactions import TransactionManager #import the transaction manager class to the Python environment 
 clr.AddReference("RevitAPI") #add the Revit API to the CLR
import Autodesk #add the Autodesk class to the Python environment 
from Autodesk.Revit.DB import * #import every class of the Revit API to the Python environment

###### Global variables and inputs ######
 doc = DocumentManager.Instance.CurrentDBDocument #the current Revit document
 wall1 = UnwrapElement(IN[0]) #import the wall provided at IN[0] of the Dynamo environment and convert to native Revit elements
 gap = IN[1] #the gap in native Revit units

############## split wall ###############
 TransactionManager.Instance.EnsureInTransaction(doc) #start transaction
 loc1 = wall1.Location#get the location of the current wall
 crv1 = loc1.Curve#get the curve of the current wall
 start1 = crv1.Evaluate(0, True) #get the XYZ at the start of the current wall
 end2 = crv1.Evaluate(1, True) #get the XYZ at the end of the current wall
 len = crv1.Length#get the lenght of the current wall 
 end1 = crv1.Evaluate(len/2-gap/2,False) #get the end of the first wall by subtracting half the gap from half of the width
 start2 = crv1.Evaluate(len/2+gap/2,False) #get the start of the new wall by adding half of the gap to half of the width
 crv1 = Line.CreateBound(start1, end1) #generate the new curve for the first wall
 crv2 = Line.CreateBound(start2, end2) #generate the new curve for the second wall
 wall2Id = ElementTransformUtils.CopyElement(doc, wall1.Id, XYZ(0,0))[0] #create the new wall
 wall2 = doc.GetElement(wall2Id) #get the new wall
 loc2 = wall2.Location#get the new wall's location 
 loc2.Curve = crv2 #set the new wall's location to the new curve
 loc1.Curve = crv1 #set the old wall's location to the new curve
 TransactionManager.Instance.TransactionTaskDone() #end transaction

##### Return the results to Dynamo ######
 OUT = wall1, wall2

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes