Author Topic: ALIGNED LISP  (Read 9478 times)

0 Members and 1 Guest are viewing this topic.

Fabricio28

  • Swamp Rat
  • Posts: 670
ALIGNED LISP
« on: August 03, 2012, 12:36:15 PM »
 :mrgreen:
Thanks in advance.
 Fabricio

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: ALIGNED LISP
« Reply #1 on: August 03, 2012, 12:36:44 PM »
Hey guys,
 I need a lisp that calculates the distance between two points and put the distance in the midpoint above the line.
 The aligned command is a block, I need a simple text for the distance.
 Please, help me out...

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: ALIGNED LISP
« Reply #2 on: August 03, 2012, 12:50:26 PM »
Sorry guys...
 I've found this lisp.
 
Thanks anyway
 :lmao:

Lee Mac

  • Seagull
  • Posts: 12923
  • London, England
Re: ALIGNED LISP
« Reply #3 on: August 03, 2012, 12:59:29 PM »
Here is a very simple fully-commented example that you (and maybe others) can learn from:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:dmid ( / an di p1 p2 tp ) ;; Define function, localise variables
  2.     (if ;; if the following test expression returns a non-nil value
  3.         (and ;; all of the following expressions must return a non-nil value
  4.              ;; Collect the first point from the user, assign to p1
  5.              (setq p1 (getpoint "\nSpecify First Point: "))
  6.              ;; Collect the second point from the user, rubber-band to p1, assign to p2
  7.              (setq p2 (getpoint "\nSpecify Second Point: " p1))
  8.         ) ;; end and
  9.         (progn ;; Evaluate the following expressions as the 'then' expression for the if function
  10.             ;; Calculate the distance between the points
  11.             (setq di (distance p1 p2)
  12.             ;; Calculate the angle between the points
  13.                   an (angle p1 p2)
  14.             ;; Calculate the point for the Text
  15.                   tp (polar
  16.                          (polar p1 an (/ di 2.0)) ;; Line midpoint
  17.                          (+ an (/ pi 2.0))  ;; Perpendicular to Line
  18.                          (getvar 'textsize) ;; Offset by text height
  19.                      )
  20.             )
  21.             ;; Create the line between the points
  22.             (entmake
  23.                 (list
  24.                    '(0 . "LINE") ;; Entity type
  25.                     (cons 10 p1) ;; Start point
  26.                     (cons 11 p2) ;; End point
  27.                 ) ;; end list
  28.             ) ;; end entmake
  29.             ;; Create the text to display the distance
  30.             (entmake
  31.                 (list
  32.                    '(0 . "TEXT") ;; Entity type
  33.                     (cons 10 tp) ;; Insertion Point
  34.                     (cons 11 tp) ;; Alignment POint
  35.                     (cons  1 (rtos di)) ;; Content
  36.                     (cons 40 (getvar 'textsize)) ;; Height
  37.                     (cons 50 an) ;; Angle
  38.                    '(72 . 1) ;; Center
  39.                    '(73 . 2) ;; Middle
  40.                 ) ;; end list
  41.             ) ;; end entmake
  42.         ) ;; end progn
  43.     ) ;; end if
  44.     (princ) ;; Suppress the return of the last evaluated expression
  45. ) ;; end defun
  46. (princ) ;; Suppress return of expression evaluated on load

Many improvements could be made to account for text readability and UCS.

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: ALIGNED LISP
« Reply #4 on: August 03, 2012, 01:34:19 PM »
Please Lee,
Could you explain how use this lisp??

Thanks

Lee Mac

  • Seagull
  • Posts: 12923
  • London, England
Re: ALIGNED LISP
« Reply #5 on: August 03, 2012, 02:16:41 PM »
The program is as you described in Reply#1  :?

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: ALIGNED LISP
« Reply #6 on: August 03, 2012, 02:33:54 PM »
Yes Lee, I know...
What's the commando this routines??
I apploaded the lisp, but I can't use it.

Kind Regards

owenwengerd

  • Bull Frog
  • Posts: 451
Re: ALIGNED LISP
« Reply #7 on: August 03, 2012, 03:04:44 PM »
Yes Lee, I know...
What's the commando this routines??
I apploaded the lisp, but I can't use it.

Kind Regards

Dude, seriously? This is a programming group, not a group for requesting free lisp routines. IMO, if you post here, you should be a programmer or learning to become one. Your response indicates that you're neither learned nor interested in investing any effort in learning, which is rude and insulting to the rest of the members. Lee Mac wrote a custom lisp routine to your specification for free. He probably skipped some other important activity so he could spend an hour or two to help you out. Now you can't be bothered to invest 10 minutes to read the code and do some internet research in order to learn how to use it? I think you owe Lee Mac an apology.

Lee Mac

  • Seagull
  • Posts: 12923
  • London, England
Re: ALIGNED LISP
« Reply #8 on: August 03, 2012, 03:05:41 PM »
What's the commando this routines??

The command for the function is dmid. For future reference, you can determine the command for a program by looking at the string following a 'c:' prefix in a defun expression, in this case, we have c:dmid, so the command is dmid (distance at midpoint)

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: ALIGNED LISP
« Reply #9 on: August 03, 2012, 03:33:08 PM »
Lee,
I'm sorry to bother you, but I didn't get it.
I pasted the code  in Visual Lisp editor and I appload the file.
I've tried use dmid, but the AutoCad don't recognize the command.

I'm doing something worng
Take a look in dmid.lisp, please.

Best Regards

ronjonp

  • Needs a day job
  • Posts: 7531
Re: ALIGNED LISP
« Reply #10 on: August 03, 2012, 03:39:22 PM »
Looks like the numbers are copied to each line of the code for some reason :? What browser are you using?

Try the attached file.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: ALIGNED LISP
« Reply #11 on: August 03, 2012, 03:43:00 PM »
The code are copied in the single line in the Visual Lisp.
I don't know why. So I had to put in order the numbers.
I'm using Internet Explorer.

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: ALIGNED LISP
« Reply #12 on: August 03, 2012, 03:50:28 PM »
Thanks ronjonp,
Your lisp works.
I don't know where was my mistake. Thanks anyway

Thanks Lee,
Your routine is fantastic. It was exactly I needed


Thanks all for you!
me :ugly: hahahahaha

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: ALIGNED LISP
« Reply #13 on: August 04, 2012, 04:17:15 AM »
I don't know where was my mistake.
I think this was it:
I'm using Internet Explorer.
In Chrome/FireFox when I select the code in Lee's post it doesn't select the numbers to the left of each line.

If you want to stick with using IE, then I'd suggest you install something like Notepad++. It has a feature to select columns of text - which would make it a lot simpler to remove the line numbers from the front of each line in the LSP file.

Edit: Just tested. IE is even worse than I thought  :ugly: It doesn't even copy-paste the lines as lines. Copying Lee's code to normal Notepad puts everything (including the line numbers) all on one single line. Tht's going to cause even greater issues due to the comments in the code. You won't even be able to use VLIDE's autoformat to try and fix this. See the screen captures
« Last Edit: August 04, 2012, 04:30:30 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

GP

  • Newt
  • Posts: 83
  • Vercelli, Italy
Re: ALIGNED LISP
« Reply #14 on: August 04, 2012, 04:36:28 AM »
In Chrome/FireFox when I select the code in Lee's post it doesn't select the numbers to the left of each line.

If you want to stick with using IE, then I'd suggest you install something like Notepad++. It has a feature to select columns of text - which would make it a lot simpler to remove the line numbers from the front of each line in the LSP file.

Or quote the message, select code, copy and paste.  :-)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: ALIGNED LISP
« Reply #15 on: August 04, 2012, 04:40:23 AM »
Ja, that might work  ;)

Just a small question on the topic of this thread: Why not use an aligned dimension? You could set your dimstyle to have no tick/arrow marks, then draw it with no offset from measured points. Would sort out UCS issues and allow you to stretch the "line" afterwards - updating the text.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

piffling

  • Guest
Re: ALIGNED LISP
« Reply #16 on: August 04, 2012, 09:11:15 AM »
In Chrome/FireFox when I select the code in Lee's post it doesn't select the numbers to the left of each line.
I use Firefox and when I select the code the line numbers are not highlighted but yet when I copy and paste into Notepad the numbers are there.

I want to take this opportunity to thank Lee-Mac, ronjonp, irneb and GP for a helpful conversation.

Lee Mac

  • Seagull
  • Posts: 12923
  • London, England
Re: ALIGNED LISP
« Reply #17 on: August 04, 2012, 09:24:04 AM »
Dude, seriously? This is a programming group, not a group for requesting free lisp routines. IMO, if you post here, you should be a programmer or learning to become one. Your response indicates that you're neither learned nor interested in investing any effort in learning, which is rude and insulting to the rest of the members. Lee Mac wrote a custom lisp routine to your specification for free. He probably skipped some other important activity so he could spend an hour or two to help you out. Now you can't be bothered to invest 10 minutes to read the code and do some internet research in order to learn how to use it? I think you owe Lee Mac an apology.

Though your comments in this thread appear to be unheeded, I would like to thank you for your support Owen, I do appreciate it. Perhaps I am sending the wrong message by supplying code for the program in its entirely, albeit fully commented with the intention that the OP can learn from my post, rather than blindly copy/pasting the code, which evidently appears to be the case - judging from the subsequent responses from the OP, I might have better invested the time spent annotating the code elsewhere. I think in future I shall instead provide hints to demonstrate how a task may be accomplished, or rather ask the OP to post their attempt at the problem before providing any full solution, if at all. I do enjoy programming, and like to share the programs that I write 'for fun', but maybe this generosity is sending the wrong message to the community leading to members requesting free code.

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: ALIGNED LISP
« Reply #18 on: August 04, 2012, 09:49:35 AM »
Thanks irneb,
Your tutorial is very simples, I understood everything...

Thanks all of you
you help me a lot

Kind Regards

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: ALIGNED LISP
« Reply #19 on: August 04, 2012, 10:21:21 AM »
Sorry Lee Mac,
I am so sorry to everybody.

This topic helped me a lot.
I still I don't know how to create a full lisp routine, and some people is help me and give me some tips.
Finally  I improved my knowledge in this forum.

I am really sorry guys,

owenwengerd

  • Bull Frog
  • Posts: 451
Re: ALIGNED LISP
« Reply #20 on: August 04, 2012, 10:26:32 AM »
I do enjoy programming, and like to share the programs that I write 'for fun', but maybe this generosity is sending the wrong message to the community leading to members requesting free code.

It's inevitable that you get a bit jaded over time, but I think the natural ebb and flow of generosity and jadedness in a vibrant community like this tends to maintain a good balance and average out over time. You want to be careful and not feed the trolls too much, but my advice to you is to not let *my* jaded view affect your approach too much. It's a bit like driving on the freeway: sudden changes are dangerous -- just stay in your groove and let the crazy guy through.

Lee Mac

  • Seagull
  • Posts: 12923
  • London, England
Re: ALIGNED LISP
« Reply #21 on: August 04, 2012, 10:55:48 AM »
It's inevitable that you get a bit jaded over time, but I think the natural ebb and flow of generosity and jadedness in a vibrant community like this tends to maintain a good balance and average out over time. You want to be careful and not feed the trolls too much, but my advice to you is to not let *my* jaded view affect your approach too much. It's a bit like driving on the freeway: sudden changes are dangerous -- just stay in your groove and let the crazy guy through.

Thanks Owen, that's sound advice  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ALIGNED LISP
« Reply #22 on: August 04, 2012, 11:10:31 AM »
When smart folks talk I listen, good advice Owen.  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

REGHUYES

  • Newt
  • Posts: 21
Re: ALIGNED LISP
« Reply #23 on: August 20, 2012, 06:08:32 AM »
How to modify Lee Mac  's code,without line.
I want aligned text with out lines

Lee Mac

  • Seagull
  • Posts: 12923
  • London, England
Re: ALIGNED LISP
« Reply #24 on: August 20, 2012, 06:59:37 AM »
How to modify Lee Mac  's code,without line.
I want aligned text with out lines

Read the code comments, I'm sure you could work it out  :wink: