Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Total length of multiple 2 point distances

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
RJanw01
634 Views, 10 Replies

Total length of multiple 2 point distances

I am trying to find a routine that will add up multiple 2 point distances looping until I hit enter to exit the command.

Example is the spaces between windows and doors along a single wall. I want to pick all the "wall" space points and have a total of wall.

I tried extracting the data to excel and it worked up until Excel's limitation of not adding feet-inch entries together for a sum.

 

Thanks in advance.

 

Rich

10 REPLIES 10
Message 2 of 11
hmsilva
in reply to: RJanw01

Hi Rich,

I'm a metric guy, so feet-inch are not my world...

As a demo

(defun c:demo (/ d l p1 p2)
  (setq l 0.0)
  (while (and (setq p1 (getpoint "\nEnter first point: "))
              (setq p2 (getpoint p1 "\nEnter second point: "))
         )
    (progn
      (setq d (distance p1 p2))
      (prompt (strcat "\nTotal length: " (rtos (setq l (+ l d)) 3 2)))
    )
  )
  (prompt (strcat "\nTotal length: " (rtos l 3 2)))
  (princ)
)

 See the rtos function to the correct units.

 

Henrique

EESignature

Message 3 of 11
RJanw01
in reply to: hmsilva

Thank you, works great.

Message 4 of 11
hmsilva
in reply to: RJanw01

You're welcome, Rich
Glad I could help

Henrique

EESignature

Message 5 of 11
Kent1Cooper
in reply to: RJanw01

Here's a pair of commands I made a while ago.  The one in SumDist.lsp is pretty much like hmsilva's except that it also reports each individual distance along the way.  The one in SumDistCont.lsp is for a string of continuous end-to-end distances, sparing you the need, in that situation, to pick the intermediate locations twice [once for each sub-distance] as you would need to do if using SumDist.lsp.

 

EDIT:  And now for some reason the Options are working again, so I can Edit.  So in addition to the addendum in my other Reply:

 

In either hmsilva's or either of my routines, if you want to not just have the distance reported, but to be able to later use the total cumulative distance, such as to write it out to somewhere, but not within the distance-summing routine, take the variable name out of the localized variables list at the top [hmsilva's 'l', my 'sumdist'], so the variable value will survive past the completion of the routine.  [If you alter the routines to incorporate writing it out within them, you can leave that as a localized variable.]

Kent Cooper, AIA
Message 6 of 11
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

....  The one in SumDist.lsp is pretty much like hmsilva's except that it also reports each individual distance along the way. ....


[For some reason at the moment the Options thing isn't letting me Edit my Reply, so an addendum:]

 

It also reports the distances in whatever Units and precision are current, as compared to hmsilva's routine that reports only in Engineering units to 2 decimal places.

Kent Cooper, AIA
Message 7 of 11
DC-MWA
in reply to: Kent1Cooper

Thanks Kent. The "Pickpoints" option was created using Sumdist.lsp.

It works great.

I don't think I am explaining the issue clearly. Both potions work independently.

I'm trying to have two options and be able work with them back and forth as develop the gas line size calcs.

DCMWA_0-1678807576913.png

 

If I use the "Pickpoints" and then run using "Typeit", I get this message

"bad argument type: fixnump: 97.8481"

I need these to work together.

I have assembled the parts in a little lisp so you can see how it is supposed to work.

Thank you for your time.

Message 8 of 11
DC-MWA
in reply to: DC-MWA

I did not click solved on this thread? 

I still have no solution?

Message 9 of 11
Kent1Cooper
in reply to: DC-MWA


@DC-MWA wrote:

I did not click solved on this thread? 

I still have no solution?


[This isn't your topic.  It's one I linked to with a suggestion.]

Kent Cooper, AIA
Message 10 of 11
DC-MWA
in reply to: Kent1Cooper

I know that now. Very sorry.

Message 11 of 11
Sea-Haven
in reply to: RJanw01

If you posted a dwg would have helped maybe ssget "F" can give an answer only 2 points required. I auto dimension walls using that method.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost