<?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: vla-get-centroid error in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13666262#M164469</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/587775"&gt;@SAPER59&lt;/a&gt;&amp;nbsp;try this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun rgtest (/ en obj1 pc pt ss)
 (vl-load-com)
 (command "_.UCS" "_OB" pause)
 (setq pt (getvar "lastpoint"))
 (if (setq ss (ssget pt))
  (if (and 
        (eq (cdr (assoc 0 (entget (setq en (ssname ss 0))))) "REGION")
        (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-get-centroid (list (setq obj1 (vlax-ename-&amp;gt;vla-object en))))))
      ) 
      (setq pc (vla-get-centroid obj1))
  )
 )
 (command "_.UCS" "_P")
 pc
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jun 2025 17:54:06 GMT</pubDate>
    <dc:creator>paullimapa</dc:creator>
    <dc:date>2025-06-04T17:54:06Z</dc:date>
    <item>
      <title>vla-get-centroid error</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13664452#M164449</link>
      <description>&lt;P&gt;I have a problem with some regions, when getting the centroid, function&amp;nbsp; crashes, and if I go to the object properties, centroid said&amp;nbsp; Automation Error. Region is not on the UCS plane&lt;/P&gt;&lt;P&gt;I tried setting the UCS to region object, before accessing centroid property, but crashes the same&lt;/P&gt;&lt;P&gt;It happens in many dxf files when creating region from original polyline, but in many others works perfectly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(setq en (car(entsel)))&lt;BR /&gt;(setq obj1 (vlax-ename-&amp;gt;vla-object en))&lt;BR /&gt;(setq pc (vla-get-centroid obj1));&lt;/P&gt;&lt;P&gt;;;;;here crashes and can not control with error trap in order to know before getting centroid and continue&lt;BR /&gt;(vlax-release-object obj1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If somebody knows how to solvethis. thanks&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jun 2025 23:21:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13664452#M164449</guid>
      <dc:creator>SAPER59</dc:creator>
      <dc:date>2025-06-03T23:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: vla-get-centroid error</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13665140#M164459</link>
      <description>&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Bonjour&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/587775"&gt;@SAPER59&lt;/a&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Actually I see the same concern but without “crash” just an error in the search of the centroid. &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;The concern is the entity not the software, it must be redesigned “properly” and everything will come back into order.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Amicalement&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 08:41:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13665140#M164459</guid>
      <dc:creator>-didier-</dc:creator>
      <dc:date>2025-06-04T08:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: vla-get-centroid error</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13665450#M164461</link>
      <description>&lt;P&gt;Thanks but the point is when the app is running I must detect the error before, in order not to let the function crashes , and go on alerting the user about that object has a problem.&lt;/P&gt;&lt;P&gt;The function handle hundred of dxf inserting , modifying and exporting, and if crashes, there are many dxf that have not been prcessed.&lt;/P&gt;&lt;P&gt;Thanks anyway&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 11:40:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13665450#M164461</guid>
      <dc:creator>SAPER59</dc:creator>
      <dc:date>2025-06-04T11:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: vla-get-centroid error</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13665842#M164463</link>
      <description>&lt;P&gt;Try It.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;(defun CENTROID_EXE (e / obj ll ur)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;(if (not (vl-catch-all-error-p&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;(vl-catch-all-apply 'vla-getboundingbox&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;(list (setq obj (vlax-ename-&amp;gt;vla-object e))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;'ll&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;'ur))))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;;; Calcula o centro do bounding box&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;(mapcar '/&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;(apply 'mapcar&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;(cons '+ (mapcar 'vlax-safearray-&amp;gt;list (list ll ur))))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;'(2 2))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial black,avant garde"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(defun c:centro-textobb ( / ent pt)&lt;BR /&gt;(vl-load-com)&lt;BR /&gt;(setq ent (car (entsel "\n ADD OBJ: ")))&lt;BR /&gt;(if ent&lt;BR /&gt;(progn&lt;BR /&gt;(setq pt (&lt;FONT face="arial black,avant garde"&gt;CENTROID_EXE&lt;/FONT&gt; ent))&lt;BR /&gt;(if pt&lt;BR /&gt;(progn&lt;BR /&gt;(vla-addText&lt;BR /&gt;(vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))&lt;BR /&gt;"Centro"&lt;BR /&gt;(vlax-3d-point pt)&lt;BR /&gt;2.5&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(prompt "\n NOT CENTER")&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(prompt "\n NOT SELECT.")&lt;BR /&gt;)&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 14:28:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13665842#M164463</guid>
      <dc:creator>sigmmadesigner</dc:creator>
      <dc:date>2025-06-04T14:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: vla-get-centroid error</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13665994#M164466</link>
      <description>&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4335289" target="_self"&gt;&lt;SPAN class=""&gt;Thanks sigmmadesigner, but this is the center of max/min coordinates of a polyline obtained by boundingbox, but not the &lt;SPAN&gt;&amp;nbsp;center of area, what is the centroid.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4335289" target="_self"&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Thanks anyway&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 15:50:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13665994#M164466</guid>
      <dc:creator>SAPER59</dc:creator>
      <dc:date>2025-06-04T15:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: vla-get-centroid error</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13666024#M164467</link>
      <description>&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Bonjour&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/587775"&gt;@SAPER59&lt;/a&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;I understand, then may be with a test like this you can loop over the bad object and continue with the rest&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;(setq ent (car (entsel "Select region")))
(setq vla (vlax-ename-&amp;gt;vla-object ent))
(setq result (vlax-safearray-&amp;gt;list (vlax-variant-value (vla-get-Centroid vla))))
(if (not (= 'LIST (type result)))
  (alert "Error in centroid search ")
  )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Amicalement&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 16:07:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13666024#M164467</guid>
      <dc:creator>-didier-</dc:creator>
      <dc:date>2025-06-04T16:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: vla-get-centroid error</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13666262#M164469</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/587775"&gt;@SAPER59&lt;/a&gt;&amp;nbsp;try this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun rgtest (/ en obj1 pc pt ss)
 (vl-load-com)
 (command "_.UCS" "_OB" pause)
 (setq pt (getvar "lastpoint"))
 (if (setq ss (ssget pt))
  (if (and 
        (eq (cdr (assoc 0 (entget (setq en (ssname ss 0))))) "REGION")
        (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-get-centroid (list (setq obj1 (vlax-ename-&amp;gt;vla-object en))))))
      ) 
      (setq pc (vla-get-centroid obj1))
  )
 )
 (command "_.UCS" "_P")
 pc
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 17:54:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13666262#M164469</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-06-04T17:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: vla-get-centroid error</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13666714#M164478</link>
      <description>&lt;P&gt;Thanks paullimapa, I coudln't find the right use of catching error&lt;/P&gt;&lt;P&gt;Works perfectly and let me avoid object with problem and continue with others without crashing&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jun 2025 00:16:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13666714#M164478</guid>
      <dc:creator>SAPER59</dc:creator>
      <dc:date>2025-06-05T00:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: vla-get-centroid error</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13666716#M164479</link>
      <description>&lt;P&gt;you are welcome...cheers!!!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jun 2025 00:22:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-get-centroid-error/m-p/13666716#M164479</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-06-05T00:22:36Z</dc:date>
    </item>
  </channel>
</rss>

