<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dimensioning elements - Error: dimension are no longer parallel. Plot twist: they are parallel in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/dimensioning-elements-error-dimension-are-no-longer-parallel/m-p/12793182#M5092</link>
    <description>&lt;P&gt;Not sure this might help, worth a try any way, there is an Id property for edges and Faces, that might come handy for this case. I mean to over run the hurdle of switches between Stable Reference tokens, you can do the same and extract the &lt;A href="https://www.revitapidocs.com/2024/abb781de-203f-4035-784b-713e65cca169.htm" target="_blank" rel="noopener"&gt;Face.Id&lt;/A&gt;, or &lt;A href="https://www.revitapidocs.com/2024/abb781de-203f-4035-784b-713e65cca169.htm" target="_blank" rel="noopener"&gt;Edge.Id&lt;/A&gt; , depending on what dimension line is connected to. Then after from this Id you can try to get the same from the new Beam, which eventually you can bring out the true references out of the new beam. then create the new dimension to these references.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure this is the perfect solution or addresses the why you have 4 out of 20 that didn't work. Will be glad if you can share your findings.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 May 2024 14:46:31 GMT</pubDate>
    <dc:creator>Moustafa_K</dc:creator>
    <dc:date>2024-05-23T14:46:31Z</dc:date>
    <item>
      <title>Dimensioning elements - Error: dimension are no longer parallel. Plot twist: they are parallel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/dimensioning-elements-error-dimension-are-no-longer-parallel/m-p/12793003#M5091</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm currently working on script that will add new elements (of categories Structural Framing, and Parts) to assembly and will update dimension lines and tags in views from that assembly.&lt;/P&gt;&lt;P&gt;Mostly I've finished this tool however in some special cases I'm getting warning that "&lt;SPAN&gt;dimension are no longer parallel". Depending on assembly it occurs on 3-4 dimension lines (structural framng elements) out of 20.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I've tried to recreate those dimensions with getting dimensioned faces instead of references the same error got posted, (it works that it gets Stable Representation from reference then cycles through element geometry/faces until it finds face that has the same Stable Representation and adds that Reference to new ReferenceArray). Only after adding UniqueId of element, adding information that it's instance, then parsing reference form stable representation I would be able to recreate those dimensions. On the other hand I can't add it to every reference as the error appears on different assembly. I'm thinking of using Failure Api but I'm afraid this issue may occur to only few of the newly added elements so adding "INSTANCE" to each element is asking for troubles.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now I'd like to ask if someone know how to get information when those references should have added information ifthey are coming from instance&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;And my code to recreate problematic dimension line:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# -*- coding: utf-8 -*-
"""
"""
from pyrevit import revit, DB
from Autodesk.Revit.UI.Selection import ObjectType, ISelectionFilter
from Autodesk.Revit.Exceptions import OperationCanceledException

#from System import Windows
from System.Collections.Generic import List

doc = revit.doc
uidoc = revit.uidoc
ops = DB.Options()
ops.ComputeReferences = True
ops.IncludeNonVisibleObjects = True


def SolidFromBeam(beam):
    """returns solid from StructuralFraming element"""
    cat_solid = DB.Solid
    beam_geom = beam.get_Geometry(ops)
		
    if beam.HasModifiedGeometry():
        for geom in beam_geom:
            if geom.GetType() == cat_solid:
                if geom.Volume &amp;gt; 0:
                    return geom

    else:
        for geom in beam_geom:
            if geom.GetType() == DB.GeometryInstance:
                ig = DB.GeometryInstance.GetInstanceGeometry(geom)
                for element in ig:
                    if element.Volume &amp;gt; 0:
                        return element

class EverythingISelectionFilter(ISelectionFilter):
    def AllowElement(self, elem):
        return True

def SelectModelElement():
    try:
        reference = uidoc.Selection.PickObject(ObjectType.Element, EverythingISelectionFilter(), "Select Element")
    except OperationCanceledException:
        pass
    else:
        element = doc.GetElement(reference)
        return element


with revit.Transaction("WTF"):

    dim = SelectModelElement()

    if dim != None:

        dim_view = dim.View
        dim_type = DB.Document.GetElement(doc, dim.GetTypeId())
        dim_style = dim_type.get_Parameter(DB.BuiltInParameter.LINEAR_DIM_TYPE).AsInteger()

        ops.View = dim_view
        if dim_style == 1:
            style = "continous"
        if dim_style == 3:
            style = "cummulative"
        
        location_line = dim.Curve.Clone()



        list_of_new_stable_representation = []
        list_of_original_stable_representations = []

        original_reference_array = dim.References
        original_stable_representations = ""
        list_of_elements =[]
        n = 1
        for reference in original_reference_array:
            element_id = reference.ElementId
            element = DB.Document.GetElement(doc, element_id)
            list_of_elements.append(element)
            stable_representation = reference.ConvertToStableRepresentation(doc)
            list_of_original_stable_representations.append(stable_representation)
            original_stable_representations += str(n) + '\t' + str(element_id) + '\t' + stable_representation + ';\n'

            n += 1

        new_stable_representations = ''


        new_reference_array = DB.ReferenceArray()
        n = 1

        for item, representation in zip(list_of_elements, list_of_original_stable_representations):

            solid = SolidFromBeam(item)
            faces = solid.Faces
            for face in faces:
                reference = face.Reference
                sr = reference.ConvertToStableRepresentation(doc)
                if "INSTANCE" in representation:
                    if sr in original_stable_representations:# and sr not in new_stable_representations:
                        list_of_new_stable_representation.append(sr)
                        #https://thebuildingcoder.typepad.com/blog/2016/04/stable-reference-string-magic-voodoo.html
                        unique_id = item.UniqueId
                        new_stable_reference = str(unique_id) + ':0:INSTANCE:' + sr
                        new_reference = DB.Reference.ParseFromStableRepresentation(doc, new_stable_reference)
                        new_reference_array.Append(new_reference)
                        new_stable_representations += str(n) + '\t' + str(item.Id) + ';\t'+ new_stable_reference + ';\t' + str(face.FaceNormal) + ';\t'+ str(face.Origin) +  '\n'
                        n += 1
                else:
                    new_reference_array.Append(reference)
                                    
        """
        print("Verified number of element: \t%s" %len(list_of_elements))
        print("Original ReferenceArray size: \t%s" %original_reference_array.Size)
        print(original_stable_representations)
        print("New ReferenceArray size: \t%s" %len(list_of_new_stable_representation))
        print(new_stable_representations)
        #"""

        new_dimension = doc.Create.NewDimension(dim_view, location_line, new_reference_array, dim_type)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Notes:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;GetSymbolGeometry() and GetInstanceGeometry() retrieves only Line elements from "INSTANCE" items.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In case of one element solid and it faces did not have stable representation used in dimension&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Solution prepared with:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2016/04/stable-reference-string-magic-voodoo.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2016/04/stable-reference-string-magic-voodoo.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 May 2024 13:50:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/dimensioning-elements-error-dimension-are-no-longer-parallel/m-p/12793003#M5091</guid>
      <dc:creator>_marcin</dc:creator>
      <dc:date>2024-05-23T13:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dimensioning elements - Error: dimension are no longer parallel. Plot twist: they are parallel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/dimensioning-elements-error-dimension-are-no-longer-parallel/m-p/12793182#M5092</link>
      <description>&lt;P&gt;Not sure this might help, worth a try any way, there is an Id property for edges and Faces, that might come handy for this case. I mean to over run the hurdle of switches between Stable Reference tokens, you can do the same and extract the &lt;A href="https://www.revitapidocs.com/2024/abb781de-203f-4035-784b-713e65cca169.htm" target="_blank" rel="noopener"&gt;Face.Id&lt;/A&gt;, or &lt;A href="https://www.revitapidocs.com/2024/abb781de-203f-4035-784b-713e65cca169.htm" target="_blank" rel="noopener"&gt;Edge.Id&lt;/A&gt; , depending on what dimension line is connected to. Then after from this Id you can try to get the same from the new Beam, which eventually you can bring out the true references out of the new beam. then create the new dimension to these references.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure this is the perfect solution or addresses the why you have 4 out of 20 that didn't work. Will be glad if you can share your findings.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 14:46:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/dimensioning-elements-error-dimension-are-no-longer-parallel/m-p/12793182#M5092</guid>
      <dc:creator>Moustafa_K</dc:creator>
      <dc:date>2024-05-23T14:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dimensioning elements - Error: dimension are no longer parallel. Plot twist: they are parallel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/dimensioning-elements-error-dimension-are-no-longer-parallel/m-p/12793357#M5093</link>
      <description>&lt;P&gt;Thank you for response. I've thought that you can only get References from dimension line, I'll check this aproach in optymalization stage, however the main issue is that I can't get correct reference from those Faces. When I use:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;new_reference_array = DB.ReferenceArray()
for face in solid:
    face_normal = face.FaceNormal
    if face_normal.IsAlmostEqualTo(dimension_direction.Negate(), 1e-5):
        reference = face_normal.Reference
        new_reference_array.Append(reference)&lt;/LI-CODE&gt;&lt;P&gt;I receive error and those references are removed from dimension. Only after modyfying stable representation:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;structural_framing_element.UniqueId + ":0:INSTANCE:" + stable_reference&lt;/LI-CODE&gt;&lt;P&gt;and parsing it from document dimension line is created correctly&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 15:36:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/dimensioning-elements-error-dimension-are-no-longer-parallel/m-p/12793357#M5093</guid>
      <dc:creator>_marcin</dc:creator>
      <dc:date>2024-05-23T15:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Dimensioning elements - Error: dimension are no longer parallel. Plot twist: they are parallel</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/dimensioning-elements-error-dimension-are-no-longer-parallel/m-p/12983794#M5094</link>
      <description>&lt;P&gt;Looks like I have solved this issue. The cause was that in order to dimension element/get correct references you need get symbol geometry. I had to take few steps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First I needed to get information if geometry of family instance element is modified. If it is, then job is easy as you can get direct access to geometry and retrieve faces/edges references to add to reference array of your dimension.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If element has not modified geometry, then you need to get dimensioned element transformation. With this you transform symbol geometry and find elements you wish to dimension. Alternatively you can go through instance geometry and retrieve its equivalent from symbol geometry using PlanarFace id number, then pass those references to reference array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 13:00:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/dimensioning-elements-error-dimension-are-no-longer-parallel/m-p/12983794#M5094</guid>
      <dc:creator>_marcin</dc:creator>
      <dc:date>2024-08-27T13:00:59Z</dc:date>
    </item>
  </channel>
</rss>

