Author Topic: How to get bigger and smaller distance  (Read 21394 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
How to get bigger and smaller distance
« on: March 06, 2007, 01:15:55 AM »
Hi Alls,
I just got this drawing from others forum,I got difficult to get bigger and smaller distance,yes that is not ellipse,my question is it possible to get as like ellipse to find major axis and minor axis distance.  :angel:
Code: [Select]
(defun massoc (key alist / x nlist)          ; Jaysen Long
  (foreach x alist
    (if
      (eq key (car x))
      (setq nlist (cons (cdr x) nlist))
      )
    )
  (reverse nlist)
  )

(defun cl3p (pcs lst / len div cnt xlst nlst)
  (setq len (length lst))
  (setq div (/ len pcs))
  (setq cnt 0)
  (repeat div
    (if
      (= pcs 3)
      (progn
(setq xlst (list (nth cnt lst)
(nth (1+ cnt) lst)
(nth (+ 2 cnt) lst)))
(setq nlst (append nlst (list xlst)))
(setq cnt (+ 3 cnt))
)                    ; progn
      )                      ; if
    )                        ; repeat
    nlst
    )                        ; defun

(defun c:test ( / ss vevo area leng obj)
  (vl-load-com)
  (if
    (setq ss (car (entsel "\nSelect an object"))) 
    (progn
      (setq vevo (vlax-ename->vla-object ss))     
      ;(vlax-dump-object vevo)
      (setq area (rtos (vla-get-area vevo)))
      (setq leng (rtos (vla-get-length vevo)))
      (setq obj (substr (vla-get-ObjectName vevo) 5 10))
      (setq co (vla-get-Coordinates vevo))         
      (setq coo (vlax-safearray->list (vlax-variant-value co)))
      (setq 3p (cl3p 3 coo))
      ; ????????
     
      (alert (strcat "\nThis object is"
     "\n"
     "\nObject name is " obj
     "\n"
     "\nArea object is " area
     "\n"
     "\nLength is " leng
     "\n"
     "\nBigger distance is" big
     "\n"
     "\nSmaller distance is" small
      )       ; progn
    (alert "\nInvalid selected object,try again")
    )         ; if
  (princ)
  )           ; defun
« Last Edit: March 06, 2007, 01:19:49 AM by Adesu »

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: How to get bigger and smaller distance
« Reply #1 on: March 06, 2007, 01:34:17 AM »
To find all is possible!
After yours to the drawing, I have not understood, that you name the big distance and that small...
Add in the drawing the dimension which need to be found.
« Last Edit: March 06, 2007, 01:36:28 AM by ElpanovEvgeniy »

Adesu

  • Guest
Re: How to get bigger and smaller distance
« Reply #2 on: March 06, 2007, 01:59:38 AM »
To find all is possible!
After yours to the drawing, I have not understood, that you name the big distance and that small...
Add in the drawing the dimension which need to be found.


Hi Elpanov,
Look at attach file,that line is approximately

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: How to get bigger and smaller distance
« Reply #3 on: March 06, 2007, 02:06:14 AM »
To me again it is not clear...
It is probably necessary to find the minimal dimensional container?

Adesu

  • Guest
Re: How to get bigger and smaller distance
« Reply #4 on: March 06, 2007, 02:13:43 AM »
To me again it is not clear...
It is probably necessary to find the minimal dimensional container?

Yes.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: How to get bigger and smaller distance
« Reply #5 on: March 06, 2007, 06:32:01 AM »
Code: [Select]
(defun c:test (/ E LST MA MI)
 (if (setq e (car (entsel "\n Select object: ")))
  (progn (setq e   (vla-copy (vlax-ename->vla-object e))
               lst nil
         ) ;_  setq
         (repeat 1000
          (vla-GetBoundingBox e 'mi 'ma)
          (setq
           lst (cons (mapcar (function -) (vlax-safearray->list ma) (vlax-safearray->list mi))
                     lst
               ) ;_  cons
          ) ;_  setq
          (vla-rotate e (vlax-3d-point 0. 0.) (/ pi 1000.))
         ) ;_  repeat
         (vla-Delete e)
   (princ "\n Bounding box object with minimal length: ")
   (princ (assoc (car (apply 'mapcar (cons 'min lst))) lst))
   (princ)
  ) ;_  progn
 ) ;_  if
) ;_  defun

test function:
Code: [Select]
Command: TEST
 Select object:
 Bounding box object with minimal length: (12462.0 0.0 15617.0)

Adesu

  • Guest
Re: How to get bigger and smaller distance
« Reply #6 on: March 06, 2007, 07:03:42 PM »
Hi Elpanov,
This code is great and simple,but I'm not yet understand,and I think not minimal only,it should include maximal too.
Thanks for your spend time for solve this problem.
Code: [Select]
Select object:
 Bounding box object with minimal length: (12462.0 0.0 15617.0)

Code: [Select]
(defun c:test (/ E LST MA MI)
 (if (setq e (car (entsel "\n Select object: ")))
  (progn (setq e   (vla-copy (vlax-ename->vla-object e))
               lst nil
         ) ;_  setq
         (repeat 1000
          (vla-GetBoundingBox e 'mi 'ma)
          (setq
           lst (cons (mapcar (function -) (vlax-safearray->list ma) (vlax-safearray->list mi))
                     lst
               ) ;_  cons
          ) ;_  setq
          (vla-rotate e (vlax-3d-point 0. 0.) (/ pi 1000.))
         ) ;_  repeat
         (vla-Delete e)
   (princ "\n Bounding box object with minimal length: ")
   (princ (assoc (car (apply 'mapcar (cons 'min lst))) lst))
   (princ)
  ) ;_  progn
 ) ;_  if
) ;_  defun

test function:
Code: [Select]
Command: TEST
 Select object:
 Bounding box object with minimal length: (12462.0 0.0 15617.0)

zemleroi

  • Guest
Re: How to get bigger and smaller distance
« Reply #7 on: March 06, 2007, 09:40:32 PM »
Здравствуйте!

Мне adesu на другом форуме посоветовал задать вопрос насчёт обмеров вам. Фигуры, которые мне необходимо замерить - это многоугольники яйцеобразной (иногда - эллиптической) формы (в моём случае это сечения сурчиных нор). Интересуют меня два измерения: большая ось и перпендикулярная ей малая ось. Для простоты измерений можно рассматривать только расстояния между вершинами многоугольника, а не все точки на нём.
Мне казалось, что это должна быть несложная задача, но на форуме Autodesk'a мне никто не смог помочь. Я прилагаю чертёж с примером фигур и их замеров.

Буду очень благодарен за помощь
Дмитрий

zemleroi

  • Guest
Re: How to get bigger and smaller distance
« Reply #8 on: March 06, 2007, 09:48:50 PM »
(По какой-то причине код, данный выше, не работает. У меня программа выдаёт:  Select object: ; error: no function definition: VLAX-ENAME->VLA-OBJECT)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get bigger and smaller distance
« Reply #9 on: March 06, 2007, 10:05:21 PM »
Quote
How do you do! To me adesu on other forum advised to present the question about the measurements to you. The figures, which I should measure - these are the polygons of egg-shaped (sometimes - elliptical) form (in my case this of the section of surchinykh burrows). Two measurements interest me: major axis and perpendicular to it minor axis. It is possible to examine the distances between the apexes of polygon, but not all points on it only for simplicity of measurements. It seemed me that this must be the simple task, but to me no one not smog soak on forum Autodesk'a. I apply drawing with an example of figures and their measurements. I will be very grateful for help
Dmitriy

Quote
(on some to reason the code, given above, does not work. In me the program issues: ; error: no function definition: VLAX-ENAME->VLA-OBJECT)

Added :
using http://babelfish.altavista.com/
« Last Edit: March 06, 2007, 10:18:11 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get bigger and smaller distance
« Reply #10 on: March 06, 2007, 10:16:25 PM »
Dmitriy

Sorry. I don't understand the question.
In that drawing .
What do you mean by Minimal ?
What do you mean by Maximal ?

What are the rules ?

//-------

Which version of AutoCAD do you use. ?

//---------

This is a guess .

Do you want the center of gravity for the object ..

Then

Calculate the minimun and maximum length lines that can pass through the center and are contained within the object ?
///------------



kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

zemleroi

  • Guest
Re: How to get bigger and smaller distance -translation of the last post
« Reply #11 on: March 06, 2007, 10:20:22 PM »
Sorry, here is the translation of my previous post into English:

Hello!
Adesu advised me to consult this forum with a question about automating measurements. I am using AutoCAD 2004. The objects that I am trying to measure are egg-shaped (sometimes elliptical) polygons (these are sections of woodchuck burrows). The measurements that I am looking for are the major (longer) axis and the minor (shorter) axis perpendicular to it. For simplicity's sake, it is possible to only consider the vertices of the polygons, not all the points on the object. I am attaching a file with examples of objects I am measuring and example measurements of the two axes on these objects.

I would very much appreciate any help on this
Dmitri

P.S. (For some to reason the code that Yevgeny gave above, does not work for me. The message I get is: ; error: no function definition: VLAX-ENAME->VLA-OBJECT).


Adesu

  • Guest
Re: How to get bigger and smaller distance -translation of the last post
« Reply #12 on: March 06, 2007, 11:35:50 PM »
Hi zemleroi,
Add that code with "(vl-load-com) "
Quote
P.S. (For some to reason the code that Yevgeny gave above, does not work for me. The message I get is: ; error: no function definition: VLAX-ENAME->VLA-OBJECT).

zemleroi

  • Guest
Re: How to get bigger and smaller distance
« Reply #13 on: March 06, 2007, 11:48:36 PM »
Thank you Adesu! It now works. Wow, that's magic!
Is it possible to export these measurements into a txt file? I could then select multiple objects...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get bigger and smaller distance
« Reply #14 on: March 07, 2007, 12:16:36 AM »
Ahhhhh I see,

The question was "what size box will this fit in"  .. yes ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.