Get Parent Element of Sketch Model Curves


#1

I am trying to find a way to distinguish which model curves are sketch lines of elements (floors, shafts, roofs) and then distinguish which element each sketch line (model curve) belongs to.

In other words, if I have Floors A, B, and C and Shafts D and E, I want to find out that sketch lines 1,3,5,6 belong to Floor A, lines 2,4,7,8,10 belong to Floor B, lines 9,11,12 belong to Shaft D, etc…

Geometry Intersect is not an option since floors can be sloped, joined, and offset in such a way as their underlying sketch lines would not intersect their physical geometry. Is there perhaps an API method like “ModelCurve.GetParentElement” (yes, I just made that up…) that would return the element ID that each sketch line belongs to?

Sketch Model Curves and Geometry


#2

HI Ben

Have you looked into the LunchBox Floor Element Collector? It might be an easier way as it will return the ID and floor boundary for you.


#3

I have not looked at that yet, but I will give it a try. Do you know if it uses Element.Geometry to generate the boundaries? If so, then it will not work for what I want.

I’m trying to create a visual version of Copy/Monitor so that I can track the elements that have been edited from one model submission to another via view filters. The Element.Geometry methods of tracking the floor shape, volume, etc all fail in this case because one wall that joins with a floor will edit the resultant geometry, even though the underlying floor outline based on the sketch lines remains unchanged. I am looking to track purposed changes made by the human.


#4

I found an interesting rule in Element ID,

Id numbers of SketchLines for each floors are following the Id of each floors.

e.g. if id of [0]floor is ‘one’ and the next floor’s id is ‘ten’, every id of SketchLines for [0]floor must be between one & ten.

Here is a definition using above rule. I used a simple Python script

이미지 1

 

 

이미지 2


#5

What happens if the sketch is edited next week and new lines are added? Do the Element IDs renumber to preserve the sequential nature? Or would the sketch lines be 2, 3, 4, 5, 7469

Regardless of whether your discovery works for my problem, it is good to know and I’m sure there are some handy applications.


#6

This:

is the only known sure method of selecting the floor boundary curves.


#7

I just checked the LunchBox Floor Element Collector. It uses the solid geometry to generate the boundary, not the sketch lines.

The Element ID Method works for the original sketch lines, but if the sketch is edited later, the Sketch Line element IDs are completely different and non-sequential.

Floor Collector


#8

Dimitar-

That looks like it will work. Can the Python Script in Dynamo do a temporary transaction and then do an “Undo” as was proposed in the link you provided?


#9

You can create a sub- transaction as described below:

 


#10

This worked great. Thanks to you all.

GetSketch


Accesing sketch lines of a wall element
#11

Hey Ben,

 

Would you be willing to post a screenshot of your definition?

Also, I’ve been getting an error message on the script you posted:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “<string>”, line 4, in <module>
NameError: name ‘TransactionManager’ is not defined

 

Any idea what that’s about?


#12

Hi Bo,

You’ll need to import some assemblies at the start of your script. The below will most likely not work because the forum likes to eat code for breakfast:

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference(“RevitAPI”)
import Autodesk

 

So instead of copying it from here, you can check out the detailed wiki page and copy it from there:

 

 


#13

Your addition worked! Thanks Dimitar!

A new wrinkle though. I am able to get the sketchlines as Model Curves for each floor. The problem I’m coming across, however, is that because the Model Curves are sketchlines, they seem to have no underlying geometry. So if I try to convert them to geometry in Dynamo using the element.curve they return Empty Lists. And if I try to treat them like Dynamo curves, they don’t work. The funny thing is that they do show up in the geometry preview window. So I’m stumped. Any idea how to extract the geometry from these model curves?

Here’s the final python code (for future reference):

Floor Lines

 

 


#14

Moved to new thread: http://dynamobim.com/forums/topic/sketch-line-model-curves-to-dynamo-curves/


#15

Dimitar,

This is a great post, opens up the ability to control sketch lines. I am however stumbling on the Python script. I have carefully copied the Transaction exactly as you suggested to Ben and Bo, and am still getting the “from item in items” error. See screen shots below. Am I missing anything? Thanks in advance for your help.

 

Python Script

Python Error


#16

Cesar,

it should be “for item in items” and not “from item in items”.


#17

Duh!

Thanks Konrad!