lisp - getpoint geometric center of last entity

lisp - getpoint geometric center of last entity

nmckelveyHMN4X
Explorer Explorer
3,286 Views
6 Replies
Message 1 of 7

lisp - getpoint geometric center of last entity

nmckelveyHMN4X
Explorer
Explorer

As per the above. Looking for a little help with a lisp routine. 

 

I have to routine running that draws a region and the next step I am looking for is to set a point  as the geometric center of that region so I can use that value in the next stage of the routine. Any help for this line of code would be appreciated.

 

(SETQ p3 (getpoint ……"gcenter"……."last"...???

 

Thanks in advance 

0 Likes
Accepted solutions (1)
3,287 Views
6 Replies
Replies (6)
Message 2 of 7

dbhunia
Advisor
Advisor
Accepted solution

Check >>THIS<<

 

Or if your last object is a "REGION" then try like this...

 

(setq P3 (vlax-get (vlax-ename->vla-object (entlast)) 'Centroid))

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 3 of 7

nmckelveyHMN4X
Explorer
Explorer

Thank you so much. 

 

Worked perfectly!!

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant

@nmckelveyHMN4X wrote:
...

(SETQ p3 (getpoint ……"gcenter"……."last"...???

...

If it's a closed Polyline or Spline:

 

(setq p3 (osnap (vlax-curve-getStartPoint (entlast)) "gcen"))

 

[That's assuming there's nothing else with a geometric center around that it could snap to instead, when "picked" at the object's start point.]

 

You will need to do this first, if not done already, to get that (vlax-curve...) function:

(vl-load-com)

Kent Cooper, AIA
Message 5 of 7

Michiel.Valcke
Advisor
Advisor

If it's a closed Polyline or Spline:

 

(setq p3 (osnap (vlax-curve-getStartPoint (entlast)) "gcen"))

 

[That's assuming there's nothing else with a geometric center around that it could snap to instead, when "picked" at the object's start point.]

 

You will need to do this first, if not done already, to get that (vlax-curve...) function:

(vl-load-com)


@Kent1Cooper 


Hello,

I'm sorry to restart an old post, but this might be a solution to a problem I'm currently facing. However, the part in my routine tries to get a list of handles and their corresponding geometric centers, so there will always be a lot of other objects to snap to when "picked" at the object's start point. Would turning off osmode sysvar help?

0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant

@Michiel.Valcke wrote:
....the part in my routine tries to get a list of handles and their corresponding geometric centers, so there will always be a lot of other objects to snap to when "picked" at the object's start point. Would turning off osmode sysvar help?

If you're calling for a specific Osnap mode, that would override any running mode(s) that you have set, so I think if it's not getting the geometric center of the object you want, turning OSMODE off probably would not help.

Kent Cooper, AIA
0 Likes
Message 7 of 7

john.uhden
Mentor
Mentor

Hmm.  2002 doesn't have a "gcen" snap.  That's cool.

John F. Uhden

0 Likes