Author Topic: MLeader Refinement  (Read 2090 times)

0 Members and 1 Guest are viewing this topic.

aehlers

  • Guest
MLeader Refinement
« on: January 02, 2014, 11:23:50 AM »
I'm looking for a little bit of guidance working with visual lisp, as I'm just getting my feet wet.
What I'm trying to accomplish is creating a 2-point mleader containing mtext (specific mleader style or text style prefered). The first line within the mleader "CONSTRUCTION NOTES:" I wish to be underlined, without quotes:
CONSTRUCTION NOTES:
and subsiquent lines, not underlined and originate from an excel data filter program (I'm not sure if any symbols like # * - + affect vl).
Do any of you veterans have any advice for the following lisp? (if possible I'd like to type "note" into command line, click, click, done.)

Thank you very much for your time and any help you may offer. Happy new year & cheers!

Code - Auto/Visual Lisp: [Select]
  1. (defun 2P-MLeader ( spc pt1 pt2 str / mld )
  2.  
  3.     (setq mld (vlax-invoke spc 'addmleader (append pt1 pt2) 0))
  4.  
  5.     (vla-put-textstring mld str)
  6.  
  7.     (vla-put-textrotation mld 0.0)
  8.  
  9.     (if (<= (car pt2) (car pt1))
  10.  
  11.         (progn
  12.  
  13.             (vla-setdoglegdirection mld 0 (vlax-3D-point (trans '(-1.0 0.0) 1 0 t)))
  14.  
  15.             (vla-put-textrightattachmenttype mld acattachmenttop)
  16.  
  17.             (vlax-invoke mld 'setleaderlinevertices 0 (append pt1 pt2))
  18.  
  19.         )
  20.  
  21.         (progn
  22.  
  23.             (vla-setdoglegdirection mld 0 (vlax-3D-point (trans '(1.0 0.0) 1 0 t)))
  24.  
  25.             (vla-put-textleftattachmenttype mld acattachmenttop)
  26.  
  27.         )
  28.  
  29.     )
  30.  
  31.     mld
  32.  
  33. )
  34.  
  35.  
  36.  
  37. (defun c:test ( / p1 p2 ) ;;***
  38.  
  39.     (if
  40.  
  41.         (and
  42.  
  43.             (setq p1 (getpoint "\nSelect 1st point for mleader: ")) ;;***
  44.  
  45.             (setq p2 (getpoint "\nSelect 2nd point for mleader: " p1)) ;;***
  46.  
  47.         )
  48.  
  49.         (2P-MLeader
  50.  
  51.  
  52.                 (if (= 1 (getvar 'cvport))
  53.  
  54.                     'paperspace
  55.  
  56.                     'modelspace
  57.  
  58.                 )
  59.  
  60.             )
  61.  
  62.             (trans p1 1 0)
  63.  
  64.             (trans p2 1 0)
  65.  
  66.             (strcat
  67.                 "{\\LCONSTRUCTION NOTE:\\P}"
  68.                 "NOTELINE1\\P"
  69.                 "NOTELINE2\\P"
  70.                 "NOTELINE3\\P"
  71.                 "NOTELINE4"
  72.             )
  73.  
  74.         )
  75.  
  76.     )
  77.  
  78.     (princ)
  79.  
  80. )

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: MLeader Refinement
« Reply #1 on: January 02, 2014, 01:46:50 PM »
Hi Aaron,

Just a tip since this is your first post: when posting code to the public domain, it is usually courteous to indicate the original author (even if the original code did not include an authors note, it is dutiful to indicate the source if it is known to you), else the posted code is assumed to be your own.

Lee

aehlers

  • Guest
Re: MLeader Refinement
« Reply #2 on: January 03, 2014, 06:13:21 PM »
I'm looking for a little bit of guidance working with visual lisp, as I'm just getting my feet wet.
What I'm trying to accomplish is creating a 2-point mleader containing mtext (specific mleader style or text style prefered). The first line within the mleader "CONSTRUCTION NOTES:" I wish to be underlined, without quotes:
CONSTRUCTION NOTES:
and subsiquent lines, not underlined and originate from an excel data filter program (I'm not sure if any symbols like # * - + affect vl).
Do any of you veterans have any advice for the following lisp? (if possible I'd like to type "note" into command line, click, click, done.)

An enormous thank you, :angel:, goes out to Mr. Lee Mac for helping me get started and thank you very much for your time and any help you may offer. Happy new year & cheers!

Code - Auto/Visual Lisp: [Select]
  1. (defun 2P-MLeader ( spc pt1 pt2 str / mld )
  2.  
  3.     (setq mld (vlax-invoke spc 'addmleader (append pt1 pt2) 0))
  4.  
  5.     (vla-put-textstring mld str)
  6.  
  7.     (vla-put-textrotation mld 0.0)
  8.  
  9.     (if (<= (car pt2) (car pt1))
  10.  
  11.         (progn
  12.  
  13.             (vla-setdoglegdirection mld 0 (vlax-3D-point (trans '(-1.0 0.0) 1 0 t)))
  14.  
  15.             (vla-put-textrightattachmenttype mld acattachmenttop)
  16.  
  17.             (vlax-invoke mld 'setleaderlinevertices 0 (append pt1 pt2))
  18.  
  19.         )
  20.  
  21.         (progn
  22.  
  23.             (vla-setdoglegdirection mld 0 (vlax-3D-point (trans '(1.0 0.0) 1 0 t)))
  24.  
  25.             (vla-put-textleftattachmenttype mld acattachmenttop)
  26.  
  27.         )
  28.  
  29.     )
  30.  
  31.     mld
  32.  
  33. )
  34.  
  35.  
  36.  
  37. (defun c:test ( / p1 p2 ) ;;***
  38.  
  39.     (if
  40.  
  41.         (and
  42.  
  43.             (setq p1 (getpoint "\nSelect 1st point for mleader: ")) ;;***
  44.  
  45.             (setq p2 (getpoint "\nSelect 2nd point for mleader: " p1)) ;;***
  46.  
  47.         )
  48.  
  49.         (2P-MLeader
  50.  
  51.  
  52.                 (if (= 1 (getvar 'cvport))
  53.  
  54.                     'paperspace
  55.  
  56.                     'modelspace
  57.  
  58.                 )
  59.  
  60.             )
  61.  
  62.             (trans p1 1 0)
  63.  
  64.             (trans p2 1 0)
  65.  
  66.             (strcat
  67.                 "{\\LCONSTRUCTION NOTE:\\P}"
  68.                 "NOTELINE1\\P"
  69.                 "NOTELINE2\\P"
  70.                 "NOTELINE3\\P"
  71.                 "NOTELINE4"
  72.             )
  73.  
  74.         )
  75.  
  76.     )
  77.  
  78.     (princ)
  79.  
  80. )