Author Topic: error: ActiveX Server returned the error: unknown name: Centroid (SOLVED)  (Read 4366 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1420
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
« Last Edit: April 16, 2014, 08:44:58 AM by HasanCAD »

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: error: ActiveX Server returned the error: unknown name: Centroid
« Reply #1 on: April 16, 2014, 08:23:10 AM »
Remove the Symbol T that is in front of the while function .

HasanCAD

  • Swamp Rat
  • Posts: 1420
Re: error: ActiveX Server returned the error: unknown name: Centroid
« Reply #2 on: April 16, 2014, 08:44:17 AM »
Remove the Symbol T that is in front of the while function .
Perfect,
Thanks Tharwat

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
You're welcome anytime .

ymg

  • Guest
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

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
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.")
  )
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

HasanCAD

  • Swamp Rat
  • Posts: 1420
Thnaks ymg
good trick alanjt

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox