Author Topic: get the UCS if the object is not on the current one  (Read 8894 times)

0 Members and 1 Guest are viewing this topic.

SMadsen

  • Guest
get the UCS if the object is not on the current one
« Reply #15 on: September 13, 2004, 09:09:39 AM »
Ah, it's only a matter of time when the old division error pops up  :oops:
Thanks Hendie

Keep us posted with your efforts, please

hendie

  • Guest
get the UCS if the object is not on the current one
« Reply #16 on: September 14, 2004, 06:42:46 AM »
Stig, Keith found that you could set the UCS to the object by

Code: [Select]
(setq Cobj (entsel "\nPlease select Solid or Region: "))
(vl-cmdf "ucs" "object" (cadr Cobj))

So, once I had that it was relatively easy to
Code: [Select]

;;;         Set Active Space            
  (setq Active-Doc  (vla-get-activedocument (vlax-get-acad-object))
ActiveSpace (vla-get-activespace Active-Doc)
  )
  (if (= 1 ActiveSpace)
    (setq ActiveSpace (vla-get-modelspace Active-Doc))
    (setq ActiveSpace (vla-get-paperspace Active-Doc))
  )
;;;         End Active Space  
         
(setq SoR (vlax-ename->vla-object (car Cobj)))
  (setq SoRlay (vlax-get-property SoR 'layer))
  (setq Objtype (vlax-get-property SoR 'objectname))
  (setq Cent
(vlax-safearray->list
  (vlax-variant-value
    (vlax-get-property SoR 'Centroid)
  )
)
  )
  (if (= Objtype "AcDbRegion")
    (setq Cent (trans Cent 1 0))
  )
;;; Set the Point size
  (setvar "pdsize" (getvar "dimasz"))
  (setvar "pdmode" 35)
;;; add the point
  (setq CPnt (vla-addpoint ActiveSpace (vlax-3d-point cent)))
  (vlax-put-property CPnt 'layer Sorlay)

and by saving the current UCS before running & restoring/deleting it as per your routine, the problem was solved.
The only thing I found was that setting the UCS to a solid always returned the correct coordinates, but a region's coordinates had to be translated.
I need to add error checking and something to disallow the command in paperspace/floating viewports and that should be it.

SMadsen

  • Guest
get the UCS if the object is not on the current one
« Reply #17 on: September 14, 2004, 07:52:47 AM »
Doh! I didn't think of using the pickpoint with the UCS command. Good thinking (or just bad thinking from my side heh)

You don't need to set a particular UCS to get the centroid of a solid. It can't really describe a UCS, only the faces can (the UCS command sets UCS to the nearest face if the face is planar, not to the solid itself). Which is why centroids are always given in WCS whereas regions are planar objects and return centroids in UCS.

Thanks for the update, Hendie.