<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to get the shared length between two linestring?</title><link>https://communities.bentley.com/products/programming/microstation_programming/f/bdn-vba/103527/how-to-get-the-shared-length-between-two-linestring</link><description>I want to get the shared length between two linestring. How to achieve this using vba?</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to get the shared length between two linestring?</title><link>https://communities.bentley.com/thread/311485?ContentTypeID=1</link><pubDate>Sat, 17 Jan 2015 05:58:08 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:5fe5a420-6893-424f-81f9-db545a116eab</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Dharmarajan,&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Dharmarajan&amp;quot;]Since vertices of only 2 selected elements are the same[/quote]&lt;/p&gt;
&lt;p&gt;It&amp;#39;s the most simple situation, because you have to compare vertices directly and can ignore line directions.&lt;/p&gt;
&lt;p&gt;I recommend to don&amp;#39;t compare coordinates directly as floating numbers equality is well known math problem. Consequently don&amp;#39;t use Point2dEqual (or Point3dEqual) method. In my opinion it&amp;#39;s better to use Point2dEqualTolerance (or Point3dEqualTolerance) method and to define a tolerance acceptable for your intention.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get the shared length between two linestring?</title><link>https://communities.bentley.com/thread/311484?ContentTypeID=1</link><pubDate>Sat, 17 Jan 2015 02:51:25 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:17ffefa8-ef91-40fd-a801-0204f42fff02</guid><dc:creator>Dharma Rajan</dc:creator><description>Thanks Jan. Since vertices of only 2 selected elements are the same, I accomplish it by algorithm&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get the shared length between two linestring?</title><link>https://communities.bentley.com/thread/311415?ContentTypeID=1</link><pubDate>Fri, 16 Jan 2015 07:36:43 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:88e75fb7-8c99-4958-9f48-fabb2385cbc6</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Dharmarajan&amp;quot;]I attached a simple screenshot for your reference[/quote]&lt;/p&gt;
&lt;p&gt;Well, it&amp;#39;s a bit more clear now, but still some important information is missing, at least:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Are you looking for a general solution (find all shared parts for all line elements in a model) or for a specific case (only 2 selected elements will be checked)?&lt;/li&gt;
&lt;li&gt;Is your picture a standard situation, so vertices of different elements are the same, or a situation can be more general and one element can end in a middle of a seconed one (so the vertex lies on element, not on another vertex)?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;[quote user=&amp;quot;Dharmarajan&amp;quot;]By using object.&lt;span style="color:#000000;"&gt;&lt;b&gt;&lt;span&gt;GetRegionDifference&lt;/span&gt;&lt;/b&gt;&lt;span&gt; method, it is possible to get the shared area between two shape element. &lt;/span&gt;&lt;/span&gt;[/quote]&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know, try it, it&amp;#39;s not very difficult task. I guess it will not work, because region difference relates to closed elements, not linear. But as I wrote, it has to be tested.&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Dharmarajan&amp;quot;]Similarly, Is there any such inbuilt function is available for Linestring(apart from writing a alogrithm)?[/quote]&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know about any such functionality. But if vertices of lines are the same, the alghoritm is not very complex.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get the shared length between two linestring?</title><link>https://communities.bentley.com/thread/310959?ContentTypeID=1</link><pubDate>Tue, 13 Jan 2015 11:47:27 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:269ba3e8-25da-4009-9b09-b498c18263e1</guid><dc:creator>Dharma Rajan</dc:creator><description>&lt;p style="margin-left:30px;"&gt;Hi Artur,&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;I attached a simple screenshot for your reference, in which the blue and yellow colored elements represents two individual line elements and the Magenta color represents the shared part/length between them.&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;Hi Jan,&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;i&gt;By using object&lt;/i&gt;.&lt;span style="color:#000000;"&gt;&lt;b&gt;&lt;span&gt;GetRegionDifference&lt;/span&gt;&lt;/b&gt;&lt;span&gt; method, it is possible to get the shared area between two shape element. Similarly, Is there any such inbuilt function is available for Linestring(apart from writing a alogrithm)?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;a href="/cfs-file/__key/communityserver-discussions-components-files/53220/SharedLines.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-discussions-components-files/53220/SharedLines.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get the shared length between two linestring?</title><link>https://communities.bentley.com/thread/310230?ContentTypeID=1</link><pubDate>Tue, 06 Jan 2015 10:37:57 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:fadf8fdf-5b28-4b4c-a446-8c963be041f2</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Dharmarajan,&lt;/p&gt;
&lt;p&gt;I agree with Artur is not quite clear what is your requirement and under what conditions.&lt;/p&gt;
&lt;p&gt;Based on some preliminary assumptions in my opinion your question is not the right one. If you define &amp;quot;shared length&amp;quot; as a part, which is the same for two separate lines (the lines overlap), the basic question is about finding a proper algorithm, which does not depend on any particular development language in any way. After the algorithm is found / investigated, it&amp;#39;s time to make the second step and try to implement it using chosen language. The language adds own extra constraints, so not all languages are efficient to implement all algorithm.&lt;/p&gt;
&lt;p&gt;A complexity of the algorithm can vary a lot depending on your requirements and conditions: To solve the problem for two already selected lines is completely different comparing to general approach &amp;quot;test all elements, find their line segmenets and test them all&amp;quot;.&lt;/p&gt;
&lt;p&gt;For the most simple case, when two lines (not line strings) are already selected, there are some off-hand ideas what to test:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Line ranges: If they don&amp;#39;t overlap, not reason to test them further.&lt;/li&gt;
&lt;li&gt;Line vectors: If they are not the same, the can intersect but not overlap. You have to take care about negative direction, because A-&amp;gt;B and B-&amp;gt;A has to be evaluated as the same, but in a plain vector algebra they are different vectors.&lt;/li&gt;
&lt;li&gt;If the lines are in the same area and have the same direction, test if start/end point of one line lies on a vector of the second line. If yes, evaluate all possible cases, I think there are only several exist.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I guess there are plenty of ways how to optimize the process, but there is the rule to implement what works at first and optimize after the functionality is tested.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get the shared length between two linestring?</title><link>https://communities.bentley.com/thread/310226?ContentTypeID=1</link><pubDate>Tue, 06 Jan 2015 09:54:00 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:0c5628a5-01e4-4582-a9d2-939d51040dfb</guid><dc:creator>Artur Goldsweer</dc:creator><description>Hi Dharmarajan, &lt;br /&gt;
I am unsure if I completely understand your question. Could you please describe this more in detail. &lt;br /&gt;
If possible post a small dgn file as example.  &lt;br /&gt;
Thanks &lt;br /&gt;
Artur&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>