TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on April 16, 2014, 08:13:07 AM

Title: error: ActiveX Server returned the error: unknown name: Centroid (SOLVED)
Post by: HasanCAD on April 16, 2014, 08:13:07 AM
This part of code
Code: [Select]
  (while T
    (setq p1 (getpoint "\nPick Point inside shape"))
    (vl-cmdf "_.-boundary" "_A" "_I" "_N" "" "_O" "_R" "" "_non" p1 "")
    (setq obj (vlax-ename->vla-object (entlast)))
    (setq cent (vlax-safearray->list (vlax-variant-value (vla-get-centroid obj))))
    (vl-cmdf "POINT" (trans cent 1 0))
    (vla-delete obj)
    )

Working perfect but Gives Error
Code: [Select]
error: ActiveX Server returned the error: unknown name: Centroid
Title: Re: error: ActiveX Server returned the error: unknown name: Centroid
Post by: Tharwat on April 16, 2014, 08:23:10 AM
Remove the Symbol T that is in front of the while function .
Title: Re: error: ActiveX Server returned the error: unknown name: Centroid
Post by: HasanCAD on April 16, 2014, 08:44:17 AM
Remove the Symbol T that is in front of the while function .
Perfect,
Thanks Tharwat
Title: Re: error: ActiveX Server returned the error: unknown name: Centroid (SOLVED)
Post by: Tharwat on April 16, 2014, 08:45:16 AM
You're welcome anytime .
Title: Re: error: ActiveX Server returned the error: unknown name: Centroid (SOLVED)
Post by: ymg on April 16, 2014, 09:17:32 AM
HasanCad,

In addition to Tharwat's suggestion, you will get this error when
the boundary command cannot find a closed boundaries.

So the error message you are seeing is telling you that
there is no closed boundaries around the point you have chosen,
therefore no centroid.

In other word obj does not exist.

ymg
Title: Re: error: ActiveX Server returned the error: unknown name: Centroid (SOLVED)
Post by: alanjt on April 16, 2014, 02:54:28 PM
Consider this...

Code: [Select]
(while (setq p1 (getpoint "\nPick Point inside shape"))
  (setq obj (entlast))
  (vl-cmdf "_.-boundary" "_A" "_I" "_N" "" "_O" "_R" "" "_non" p1 "")
  (if (not (equal obj (setq obj (entlast))))
    (progn (vl-cmdf "_.point" "_non" (trans (vlax-get (setq obj (vlax-ename->vla-object obj)) 'Centroid) 1 0))
           (vla-delete obj)
    )
    (princ "\nCentroid could not be determined.")
  )
)
Title: Re: error: ActiveX Server returned the error: unknown name: Centroid (SOLVED)
Post by: HasanCAD on April 20, 2014, 07:12:57 AM
Thnaks ymg
good trick alanjt
Title: Re: error: ActiveX Server returned the error: unknown name: Centroid (SOLVED)
Post by: alanjt on April 21, 2014, 12:57:24 PM
Thnaks ymg
good trick alanjt
:-)