Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revit Api "Get Warning" Method does not get parent elements for sketch lines

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
2545 Views, 14 Replies

Revit Api "Get Warning" Method does not get parent elements for sketch lines

Dear Forum,

 

I am retrieving warning messages for quality and reviewing purposes using the API.

 

The problem I currently have is that "GetFailingElements" Methods does not provide the parent element when warning related to a sketch line. similar to the Revit Warning List using the "Review Warnings" Revit Command. This is quite important to know, because element id of sketch lines are not possible to select by id if not being in the sketch mode receiving the error below:

image_2.JPG

 

For Example:

I have a "Line in Sketch is slightly off axis.." error message. Going to the "Review  Warnings" Command I see the sketch model line Id and the parent Floor element Id.

 

image_1.JPG

However, when tracking this warning element by Revit API, it seems that parent element id is missing from the Warning list.

image_3.JPG

Could you please confirm that Revit API functionality is currently limited on getting the parent element Id of a Warning sketch model line? 

 

Any help would be much appreciated.

 

Kind Regards,

Alexandros

14 REPLIES 14
Message 2 of 15
Yien_Chao
in reply to: Anonymous

i use the API directly, and it usually give you the warning message and both of the faulty elements.

dont know why the dynamo node only gets one of them.

Message 3 of 15
Anonymous
in reply to: Yien_Chao

 

Can you confirm if you test it in a "Line in Sketch is slightly off axis.." warning?

 

I am wondering what method and which environment you use ?

 

I also implemented the same using python and still getting the same problem.

 

Below is the code I am using:

 

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

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

# Get the document
doc = DocumentManager.Instance.CurrentDBDocument data = IN
Warnings=doc.GetWarnings() output=[] description=[] elements=[] severity=[] failureDefinitionId =[]
for i in Warnings: description.append(i.GetDescriptionText ()) elements.append(i.GetFailingElements()) severity.append(i.GetSeverity()) failureDefinitionId .append(i.GetFailureDefinitionId ()) OUT = [description,elements,severity,failureDefinitionId]

 

None of the GetDescriptionText, GetFailingElements, GetSeverity and GetFailureDefinitionId  methods provide the Parent Element of the sketch model line.

 

Thanks

Alexandros

 

Message 4 of 15
Yien_Chao
in reply to: Anonymous

works fine here...

you have to add the GetElement() method:

 

ex:

List=[]

for i in warn.GetFailingElements():
        List.append(doc.GetElement(i))

Message 5 of 15
Yien_Chao
in reply to: Anonymous

import clr


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

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
doc = DocumentManager.Instance.CurrentDBDocument

data = IN

Warnings=doc.GetWarnings()

description=[]
elements=[]



for i in Warnings:
	description.append(i.GetDescriptionText ())
	x = i.GetFailingElements()
	for j in x:
		elements.append(doc.GetElement(j))
	
	

OUT = [description,elements]

i just modified your code a little bit. 🙂

Message 6 of 15
Anonymous
in reply to: Yien_Chao

 
 
 
 
 
 

Many thanks for the code and for your help! 

 

I slightly modified your code adding the sub group of element in order to show all elements per warning.

 

However, I still cannot get it working.

 

My results below show that the "Line in Sketch is Slightly off Axis.." Warning does not output the parent element using the  GetFailingElements and the GetElement methods.

 

I am attaching also a Revit model with few floor elements which I am currently having trouble. Could you please check if you can get both failing sketch model line it and its parent floor element? Currently I can only get the model curve element and not the parent floor.

 

https://1drv.ms/u/s!Aq7EhA3iEgyJnj1kzgVlDKaDh3s0?e=kZvERL

 

 

image_4.JPG

 

import clr


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

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
doc = DocumentManager.Instance.CurrentDBDocument

data = IN

Warnings=doc.GetWarnings()

description=[]
elements=[]



for i in Warnings:
	description.append(i.GetDescriptionText ())
	x = i.GetFailingElements()
	sub=[]
	for j in x:
		sub.append(doc.GetElement(j))
	
	elements.append(sub)

OUT = [description,elements]

 

 

 

Message 7 of 15
Yien_Chao
in reply to: Anonymous

strange! it works here with your file!

Message 8 of 15
Anonymous
in reply to: Yien_Chao

Hi  Yien_Chao,

 

Many thanks for taking the time to reply.

 

The same script operates completely different between your and mine computer.

 

Could you please confirm what Dynamo and Revit Version you are using?

 

It seems that there is something else I need to look at. 

 

image_5.JPGimage_6.JPGimage_7.JPG

Message 9 of 15
Yien_Chao
in reply to: Anonymous

Same version here.

Did you try on another computer ?

 

I also trid on 2020, works fine too.

Message 10 of 15
Anonymous
in reply to: Yien_Chao

Hi Yien_Chao,

 

I just tried from another computer with a different user and no Dynamo packages installed  (in case this was the issue) however, I had no luck. the same issue appears

 

As previously mentioned I am using Revit 2019.2 and Dynamo 

 

What else would it be worth testing?

 

There are still no Floor Parent elements included at my warning list.

 

image_01.PNG

Python script as noted above.

 

Many thanks

Message 11 of 15
Anonymous
in reply to: Anonymous

I meant Dynamo Core version 2.0.3.8810 and Dynamo Revit version 2.0.3.8811

Message 12 of 15
Anonymous
in reply to: Yien_Chao

Hi Yien_Chao,

I just I tried Revit 2020 and warnings work ok.

However, I cannot make this working neither in Revit 2019 nor in Revit 2018.

Would it be possible to send me your exact version of Dynamo and Revit?

Also could you please try the above script in Revit 2018 and share any results?

Any feedback would be really appreciated as we currently work mainly in 2018 and 2019.

Kind regards,

Alexandros

 

Message 13 of 15
Yien_Chao
in reply to: Anonymous

sorry for the late reply, i was on vacation.

i dont have 2018 version on my pc.

but can assure you it works for 2019 and 2020.

 

best

Message 14 of 15
j0hnp
in reply to: Anonymous

I was actually able to reproduce the issue in 2019 as well.

 

I ended up adding some redundancy to my Dynamo package, Bang! to account for it. I know it could be done better, but it seems to work for now.

 

https://github.com/johnpierson/BangForDynamo/blob/2b0936abdfd5d569cb014218bac4cab45b68a508/src/Bang/...

 

and how I heard about this issue, https://github.com/johnpierson/BangForDynamo/issues/2

john.pierson

expert elite / design technologist / dynamo package creator

designtechunraveled.com



Message 15 of 15
j0hnp
in reply to: j0hnp

linked the wrong code, here is the correct code https://github.com/johnpierson/BangForDynamo/blob/683407407302ddedca79b1f547fb73713b209073/src/Bang/...

john.pierson

expert elite / design technologist / dynamo package creator

designtechunraveled.com



Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report