Gizmo basepoint extraction

Gizmo basepoint extraction

Anonymous
Not applicable
865 Views
9 Replies
Message 1 of 10

Gizmo basepoint extraction

Anonymous
Not applicable

I would like to extract the x,y,z coordinate of a mesh using lisp. VLA-GET-BASEPOINT gives the impression that it might work but I am struggling. I am assuming it should return the basepoint the gizmo uses when the mesh is selected, as shown below.

 

MeshElbow.jpg

 

thank you in advance for your assistance.

0 Likes
Accepted solutions (3)
866 Views
9 Replies
Replies (9)
Message 2 of 10

dbroad
Mentor
Mentor
Accepted solution

I can't imagine why you would want the location of a gimzo, especially since it can be relocated.  The basepoint property only applies to xlines and rays.  3D objects have centroids but the gizmo is not located at the centroid.  As far as I can tell, the gizmo is located at the middle of the object's extents. When more than one object is selected, it is based on the middle of the extents of the selection.  If you only need the gizmo location given a single entity, this example should give you some ideas.

(defun gizmoloc	(ename / llc urc)
  (vla-getboundingbox (vlax-ename->vla-object ename) 'llc 'urc)
  (mapcar (function (lambda (a b) (/ (+ a b) 2.0)))
	  (safearray-value llc)
	  (safearray-value urc)
  )
)

;;example use
(gizmoloc (car(entsel)))

 

Architect, Registered NC, VA, SC, & GA.
Message 3 of 10

devitg
Advisor
Advisor

 

 GIZMO Meaning , as I did not knew what GIZMO means. I search and find

 

Gizmo, a bounding box used for manipulating objects in 3D modeling computer programs


So maybe the OP want the GIZMO base center point.

 

 

0 Likes
Message 4 of 10

dbroad
Mentor
Mentor
It was quite clear to me what he wanted.
Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 5 of 10

Anonymous
Not applicable

Thank you, the perfect solution to the problem posed.

But of course not what I need to establish the orientation of the mesh Smiley Sad as these 2 meshes supply exactly the same points.

 

2Elbow.jpg

 

Command: MESHANLZ

  >>  Select Mesh to Analyse  >>
Bounding Box X Value 914.5
Bounding Box Y Value 457
Bounding Box Z Value 914.5
 X = Z
Long Radius Elbow found

Command:
Command: !gizmo_point
(414654.0 -458000.0 112170.0)

Command: MESHANLZ

  >>  Select Mesh to Analyse  >>
Bounding Box X Value 914.5
Bounding Box Y Value 457
Bounding Box Z Value 914.5
 X = Z
Long Radius Elbow found

Command:
Command: !gizmo_point
(414654.0 -458000.0 112170.0)

 

The aquisiton of the centroid will be of more use I would think.

0 Likes
Message 6 of 10

dbroad
Mentor
Mentor
Accepted solution

I'm glad it solved your original post and thread topic.  If you feel that the original problem has been solved, I suggest you mark my post as the solution and pose a new topic that contains a well thought out problem statement that could be solved by something else.  Otherwise the thread will drift and any solution marking would be unrelated to the original post.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 7 of 10

dbroad
Mentor
Mentor

Thanks for the solution credit.  As far as your other direction problem, I don't think the centroid property will help you as that seems to apply only to solid objects, regions, and surfaces.  Meshes have coordinates properties but I am not sure how they relate to the mesh itself.  Perhaps someone else could help.

 

I would still suggest a new thread for that topic.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 8 of 10

Anonymous
Not applicable

Please see the attached. Smiley Happy

0 Likes
Message 9 of 10

dbroad
Mentor
Mentor
Accepted solution

David,

I am not sure you can use this but since meshes have coordinates, the mean of the coordinates might give you more information.  This function requires the mesh object as the argument.

;;parse a list and group into points
(defun groupby3 (lst)
  (if lst
    (cons (list (car lst)(cadr lst)(caddr lst))
	  (groupby3 (cdddr lst)))
    nil))

;;returns the mean of the coordinates of a mesh object
;;might be of some use.
(defun coordsmean (meshobj)
  (setq ptlist (groupby3 (vlax-get meshobj 'coordinates))
	no (length ptlist)
	)
  (mapcar (function (lambda (x) (/ x (float no))))
	  (apply 'mapcar (cons '+ ptlist))))

 

 

Architect, Registered NC, VA, SC, & GA.
Message 10 of 10

Anonymous
Not applicable

Brilliant,

Using a conditional the 4 different cases can be identified by the differing coordinates between the midpoint of the bounding points and the mean coordinate of the of the meshes.

 

Thank you very much Smiley Very Happy

0 Likes