<?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: Help with move command (Math) :) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/help-with-move-command-math/m-p/8377352#M24373</link>
    <description>&lt;P&gt;Your code is related to Civil3d, CogoPoint, CogoPoint.LabelLocation are Civil objects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doing a little search on the web, you should have found &lt;A href="https://forums.autodesk.com/t5/civil-3d-customization/set-cogopoint-labellocation-fail/m-p/5589951#M10242" target="_blank"&gt;this topic&lt;/A&gt; is about what you're looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To "move" a point, simply add a displacement vector to the point.&lt;/P&gt;
&lt;P&gt;Try something like this (not tested, I do not know Civil3d).&lt;/P&gt;
&lt;PRE&gt;acCogoPoint.ResetLabelLocation()&lt;BR /&gt;acCogoPoint.LabelLocation += selectedVector &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Nov 2018 22:26:28 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2018-11-02T22:26:28Z</dc:date>
    <item>
      <title>Help with move command (Math) :)</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-with-move-command-math/m-p/8377285#M24372</link>
      <description>&lt;P&gt;Hi, I know I'm missing something simple. I have sub that moves a cogo point label, (this is not civil 3d related) and there is something funny about my pick point. When I select the base point and then the second point the label moves just fine except it is slightly off from my second pick point. I know it has to do with the base point of the label but I cant for the life of me figure out the correct math to compensate for it. There are two images attached showing my base point pick and second pick. In the second pick image, where the cross-hairs are is where I picked for placement. (I am picking the middle of the zero, and expect the middle of the zero to be at my second point.) Any help would be appreciated.&lt;/P&gt;&lt;P&gt;P.S. I have tried getting the vector from the label base point to first pick point and compensating that into the equation but that did work. (Most likely did it wrong)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;CommandMethod("mcptlbmov")&amp;gt;
    Public Sub CogoPointLabelMove()

        'Get the current document and editor
        Dim curDb As Database = Active.Database
        Dim docEd As Editor = Active.Editor

        Try

            'Create a typedvalue array to define the filter criteria
            Dim acTypValAr(0) As TypedValue
            acTypValAr.SetValue(New TypedValue(DxfCode.Start, "AECC_COGO_POINT"), 0)

            'Assign the filter criteria to a selectionfilter object
            Dim acSelFtr As New SelectionFilter(acTypValAr)

            'Start cogo point selection prompt option
            Dim promptSelectionOptions As New PromptSelectionOptions
            promptSelectionOptions.MessageForAdding = (vbLf &amp;amp; "Select COGO Points Labels to move: ")

            'Get prompt selection results
            Dim cogoPointPromptSelectionResult = docEd.GetSelection(promptSelectionOptions, acSelFtr)

            'Set selection set
            Dim cogoPointSelectionSet As SelectionSet = cogoPointPromptSelectionResult.Value

            'If selection are cogo points
            If cogoPointPromptSelectionResult.Status = PromptStatus.OK Then

                'Start base point prompt point option 
                Dim pointPromptOptions = New PromptPointOptions(vbLf &amp;amp; "Specify base point: ")
                Dim pointPromptResult = docEd.GetPoint(pointPromptOptions)

                'If pick point is valid
                If pointPromptResult.Status &amp;lt;&amp;gt; PromptStatus.OK Then

                    Return

                End If

                'Set value from point prompt result
                Dim firstSelectedPoint = pointPromptResult.Value

                'Start second point prompt point option
                pointPromptOptions.Message = vbLf &amp;amp; "Specify second point: "
                pointPromptOptions.UseBasePoint = True
                pointPromptOptions.BasePoint = firstSelectedPoint
                pointPromptResult = docEd.GetPoint(pointPromptOptions)

                'If pick point is valid
                If pointPromptResult.Status &amp;lt;&amp;gt; PromptStatus.OK Then

                    Return

                End If

                'Set value from point prompt result
                Dim secondSelectedPoint = pointPromptResult.Value

                'Get vector between fisrt and second selected 3d points
                Dim selectedVector As Vector3d = firstSelectedPoint.GetVectorTo(secondSelectedPoint)

                'Get x and y from vector as double
                Dim selectedVectorPointY As Double = selectedVector.Y
                Dim selectedVectorPointX As Double = selectedVector.X

                'Apply move to each selected cogo point
                For Each cogoPointSelectedObject In cogoPointSelectionSet

                    'Start the transaction
                    Using trans As Transaction = curDb.TransactionManager.StartTransaction()

                        'Set dbobject and open for write
                        Dim cogoPointDbOj As Autodesk.AutoCAD.DatabaseServices.DBObject = trans.GetObject(cogoPointSelectedObject.ObjectId, OpenMode.ForWrite)

                        'Set and cast point
                        Dim acCogoPoint As CogoPoint = TryCast(cogoPointDbOj, CogoPoint)

                        'Get cogo point label location and add vector
                        Dim newCogoPointLabelY As Double = acCogoPoint.LabelLocation.Y + selectedVectorPointY
                        Dim newCogoPointLabelX As Double = acCogoPoint.LabelLocation.X + selectedVectorPointX

                        'Set the new cogo point label location
                        acCogoPoint.LabelLocation = New Point3d(newCogoPointLabelX, newCogoPointLabelY, 0)

                        'Save the changes and dispose of the transaction
                        trans.Commit()

                    End Using

                Next

            End If

            'Regen and update screen
            docEd.UpdateScreen()
            docEd.Regen()

        Catch ex As Exception&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Base Point Selected" style="width: 280px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/565036i4A6B0FC5AC91683D/image-size/large?v=v2&amp;amp;px=999" role="button" title="BasePoint.PNG" alt="Base Point Selected" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Base Point Selected&lt;/span&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Where Cross-Hairs are is Second Point Selected" style="width: 404px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/565037i5D4CAF3F774A6C2D/image-size/large?v=v2&amp;amp;px=999" role="button" title="SecondPoint.PNG" alt="Where Cross-Hairs are is Second Point Selected" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Where Cross-Hairs are is Second Point Selected&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 21:09:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-with-move-command-math/m-p/8377285#M24372</guid>
      <dc:creator>David_Prontnicki</dc:creator>
      <dc:date>2018-11-02T21:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Help with move command (Math) :)</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-with-move-command-math/m-p/8377352#M24373</link>
      <description>&lt;P&gt;Your code is related to Civil3d, CogoPoint, CogoPoint.LabelLocation are Civil objects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doing a little search on the web, you should have found &lt;A href="https://forums.autodesk.com/t5/civil-3d-customization/set-cogopoint-labellocation-fail/m-p/5589951#M10242" target="_blank"&gt;this topic&lt;/A&gt; is about what you're looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To "move" a point, simply add a displacement vector to the point.&lt;/P&gt;
&lt;P&gt;Try something like this (not tested, I do not know Civil3d).&lt;/P&gt;
&lt;PRE&gt;acCogoPoint.ResetLabelLocation()&lt;BR /&gt;acCogoPoint.LabelLocation += selectedVector &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 22:26:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-with-move-command-math/m-p/8377352#M24373</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-11-02T22:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with move command (Math) :)</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-with-move-command-math/m-p/8378246#M24374</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Your code is related to Civil3d, CogoPoint, CogoPoint.LabelLocation are Civil objects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Gile, All I meant was I thought the issue was related to my approach on moving not necessary it being a cogo point. I understand they are civil based. I will move this post to the civil side.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;Doing a little search on the web, you should have found &lt;A href="https://forums.autodesk.com/t5/civil-3d-customization/set-cogopoint-labellocation-fail/m-p/5589951#M10242" target="_blank"&gt;this topic&lt;/A&gt; is about what you're looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I did see this link, adding the reset label makes no difference so i left it out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;To "move" a point, simply add a displacement vector to the point.&lt;/P&gt;&lt;P&gt;Try something like this (not tested, I do not know Civil3d).&lt;/P&gt;&lt;PRE&gt;acCogoPoint.ResetLabelLocation()&lt;BR /&gt;acCogoPoint.LabelLocation += selectedVector &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thank you for showing me how to shorten my code, I did not know I could simply pass the vector to the label location. I appreciate that. Unfortunately&amp;nbsp; it still does not fix the issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also noticed that this approach will not work. Even my original approach does not work. The issue is if you move the label again it does not go anywhere near where you clicked. Works for the first move but from then it does not. I believe this is because I am adding the vector. I need to do this differently. I am just not sure how.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this was for a single point I would simply set the location to the second pick point like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;'Set and cast point
                        Dim acCogoPoint As CogoPoint = TryCast(cogoPointDbOj, CogoPoint)

                        acCogoPoint.ResetLabelLocation()
                        acCogoPoint.LabelLocation = secondSelectedPoint

                        'Save the changes and dispose of the transaction
                        trans.Commit()&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;Since I am doing this for multiple points; I need to get the difference between the two pick point and apply that difference to each selected cogo point label. The problem is, how do you apply when there is a negative or positive (no left or right, up, or down).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the best approach to move multiple labels based on a base point and a second point, to be able to utilize the pick point prompt with "rubber band"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 21:34:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-with-move-command-math/m-p/8378246#M24374</guid>
      <dc:creator>David_Prontnicki</dc:creator>
      <dc:date>2018-11-03T21:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help with move command (Math) :)</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-with-move-command-math/m-p/8378542#M24375</link>
      <description>&lt;P&gt;Geometrically speaking, displacing a point is done by adding a displacement vector to the point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this does not work with the CogoPoint.LabelLocation, this is due a specific behavior of this object and I cannot help you further.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2018 06:44:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-with-move-command-math/m-p/8378542#M24375</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-11-04T06:44:27Z</dc:date>
    </item>
  </channel>
</rss>

