|
Welcome, Guest.
|
||||||
| AutoLISP AutoLISP or Visual LISP, learn both here! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: 2003-12
Posts: 47
![]() |
Hi;
I am trying get the coordinates of the centroid of a closed polyline but do not have any idea at all. Is there any lisp routine whereby the coordinate can be obtained? Any help is much appreciated. Thanks. csgoh 9-7-04 |
|
|
|
|
|
#2 |
|
Active Member
Join Date: 2000-12
Location: Yorkshire
Posts: 81
![]() ![]() ![]() ![]() ![]() ![]() |
Hi csgoh
Use the REGION command to convert the Polyline to a Region, then use the MASSPROP command to list its physical properties, which include the centroid.
__________________
Regards, David |
|
|
|
|
|
#3 |
|
Member
Join Date: 2003-12
Posts: 47
![]() |
Hi David,
Thanks for the tip but using massprop only lists out the properties. But I need to get the centroid coordinates in order to insert text at this point and how can I do this? Thanks. csgoh |
|
|
|
|
|
#4 |
|
Active Member
Join Date: 2000-12
Location: Yorkshire
Posts: 81
![]() ![]() ![]() ![]() ![]() ![]() |
Hi csgoh
Sorry, forgot we were in a programming forum! Try this: [code] (setq obj (vlax-ename->vla-object (car (entsel)))) (setq centroid (vlax-safearray->list (vlax-variant-value (vla-get-centroid obj)))) [code] Hope I got the code window right! Fluffed it last time
__________________
Regards, David |
|
|
|
|
|
#5 |
|
Active Member
Join Date: 2000-12
Location: Yorkshire
Posts: 81
![]() ![]() ![]() ![]() ![]() ![]() |
Hi csgoh
Looks like I fluffed the text window again Thought you might find a practical example useful: Code:
(defun c:get_centroid ( / ename obj centroid) (setq ename (car (entsel "\nSelect polyline:"))) (command "region" ename "") (setq ename (entlast)) (setq obj (vlax-ename->vla-object ename)) (setq centroid (vlax-safearray->list (vlax-variant-value (vla-get-centroid obj)))) (command "undo" "") (command "text" "j" "mc" centroid 2.5 0.0 "CENTROID") (princ) )
__________________
Regards, David |
|
|
|
|
|
#6 |
|
Member
Join Date: 2003-12
Posts: 47
![]() |
Dear David;
Thanks but the code that you have given is good for ACAD 2K & above. How about those older version like Autocad R14 version. I have tried using entget to retrieve the centroid but to no avail and I hope you could help me. Thanks again. csgoh 11-7-04 |
|
|
|
|
|
#7 |
|
Member
Join Date: 2003-12
Posts: 47
![]() |
Hi all;
What is a variant? I went through the help section of ACAD R14 and tells if I need to obtain the centroid coordinates, I will have to use <variant>=object.Centroid and define these :- Dim anObj as object Dim retCentroid as Variant retCentroid=anObj.Centroid Could someone please tell me how to incorporate these codes into Autolisp? Some of our machines are using ACAD R14 version. Any help to get the centroid in ACAD R14 lisp codes is much appreciated. thanks. csgoh |
|
|
|
|
|
#8 |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
A variant is a variable that can hold one of several different data types. It's used in Visual Basic and has no direct counterpart in AutoLISP but can be read and assigned by functions in Visual LISP.
If I remember correctly, R14 does not have access to ActiveX or VBA - even with the add-on Visual LISP for R14c, I think (could be very wrong on this) - so you may have to get a function that does all the analyses and math itself. Did you search the AUGI Exchange?Otherwise, searching for "centroid AutoLISP" in Google turned up 238 hits so maybe there is hope. |
|
|
|
|
|
#9 | |
|
I could stop if I wanted to
Join Date: 2002-02
Location: Kansas
Posts: 462
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Quote:
|
|
|
|
|
|
|
#10 |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Well, I must be getting old. So csgohjmj should have no problem running the code David provided on R14?
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Imported Polyline and text show different | Gerhard | Revit Architecture - General | 6 | 2008-09-26 12:49 PM |
| Creating closed figures? | sinc | Land Desktop - General | 3 | 2004-06-10 07:54 PM |
| Closed loop | mjml | Revit Architecture - General | 10 | 2003-12-30 02:34 AM |
| Closed Loop Profiles | Jim Storms | Revit Architecture - Families | 4 | 2003-11-06 03:53 PM |