How to put calculated Downslope into the MText?

How to put calculated Downslope into the MText?

Anonymous
Not applicable
540 Views
6 Replies
Message 1 of 7

How to put calculated Downslope into the MText?

Anonymous
Not applicable

Hello,

I wonder how to put calculated Downslope into the MText.

The Downslope would be calculated and expressed in percents with precision to 0.001, and calculated on ground of typed valueor two picked points.

In my previous topic

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/pick-two-points-to-get-downslope-in-p...

I posted a lisp for Calculating Downslope in percents so it can be used here.

 

I posses lisps which put in Mtexts Areas of Polylines and Hatches, or Lengths of Polylines and Lines.

But: 1. in these lisps we don't pick points, but simply choose Onbjects,

and 2. they are writtenwith routines with 'vla-...' which I can;t so good for now.

 

So I can't  edit them to get lisp I want to get.

 

Could you tell me if I can mix command from AutoLisp I know, and expressions like 'vla-..'?

And what expressions should I use for picking points?

 

I would be thankfully for responses.

 

 

 

0 Likes
541 Views
6 Replies
Replies (6)
Message 2 of 7

hmsilva
Mentor
Mentor

Hi Damian,

the answer is not easy, without seeing the code you want to change...

 

From your msg tiltle:
How to put calculated Downslope into the MText?

 

If you have some difficulties with 'vla-' you may use the 'entmake' function, to create the MText entity.
e.g.

 

(entmake (list
 '(0 . "MTEXT")
 '(100 . "AcDbEntity")
 '(100 . "AcDbMText")
 ;'(7 . "YourTextStyleName")
 ;'(8 . "YourTextLayerName") 
 (cons 10 pt)
 (cons 1 TextString)
 )
 )

 

'Could you tell me if I can mix command from AutoLisp I know, and expressions like 'vla-..'?'

 

Yes, you can mix.

 

'And what expressions should I use for picking points?'

 

If you need a 'variant' to your 'vla-' and you have an 'AutoLISP' point 'pt',  you may use something like

(vlax-3d-point pt)

 

Hope that helps

Henrique

 

 

 

EESignature

0 Likes
Message 3 of 7

Anonymous
Not applicable

Thank you for these informations. Now I know something more than nothing 🙂

0 Likes
Message 4 of 7

braudpat
Mentor
Mentor

 

Hello from France


Sometimes I have to write (with standard text) the slope in percentage from 2 clicked points ...

 

So I use a small routine "SLOPEPC" from a french Developper Gilles (gile)

 

Thanks to Gilles !

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 5 of 7

hmsilva
Mentor
Mentor

@Anonymous wrote:

Thank you for these informations. Now I know something more than nothing 🙂


Applying the entmake to your DOWNSLOPE

 

; DOWNSLOPE Text
(defun c:DOWNSLOPET (/ angstring angun auni Ang DownslopePercents DownslopePercents2string Len Len_X Len_Y pt ptL1 ptL2 str XptL1 XptL2 YptL1 YptL2)
  (if (and (setq ptL1 (getpoint "\nSpecify First Point to calculate Downslope: "))
	   (setq ptL2 (getpoint "\nSpecify Second Point to calculate Downslope: "))
	   (not (equal ptL1 ptL2 1e-8))
	   (setq pt (getpoint "\nSpecify Text Insertion Point: "))
      )
    (progn
      (setq XptL1 (car ptL1))
      (setq YptL1 (cadr ptL1))
      (setq XptL2 (car ptL2))
      (setq YptL2 (cadr ptL2))
      (setq Len_X (- XptL2 XptL1))
      (setq Len_Y (- YptL2 YptL1))
      ; What if XptL1 = XptL2 --> Len_X=0?
      ;; (setq len (distance ptL1 ptL2))
      (setq Len
	     (sqrt
	       (+ (* Len_X Len_X) (* Len_Y Len_Y))
	     ); sqrt
      ); Len
      (setq angun (getvar 'aunits))
      (cond ((or (= angun 0)
		 (= angun 1)
	     )
	     (setq auni "Degrees")
	    )
	    ((= angun 2)
	     (setq auni "Gradians")
	    )
	    ((= angun 3)
	     (setq auni "Radians")
	    )
	    ((= angun 4)
	     (setq auni "Surveyor")
	    )
      )
      (setq Ang (atan Len_Y Len_X))
      (setq angstring (strcat
	     (if (minusp ang) "-" "")
	     (angtos (abs ang) angun 3)))
      ;Len_Y/Len_X = DownslopePercents/100
      (setq DownslopePercents (* (/ Len_Y Len_X) 100))
      (setq DownslopePercents2string (rtos DownslopePercents 2 3))
      ; Mode=2= Decimal, Precision=3
      (setq str (strcat "\nDownslope = " DownslopePercents2string  "%."
	    "\nAngle = " angstring " " auni "."
	     "\nLength = " (rtos Len 2 3) "."))
      (entmake (list
		 '(0 . "MTEXT")
		 '(100 . "AcDbEntity")
		 '(100 . "AcDbMText")
		 ;;'(7 . "YourTextStyleName")
		 ;;'(8 . "YourTextLayerName")
		 (cons 10 pt)
		 (cons 1 str)
	       )
      )
    )
    (prompt "\nYou did select the same point!!!")
  )
  (princ)
);defun

 

 

Henrique

 

 

EESignature

0 Likes
Message 6 of 7

Anonymous
Not applicable

Wow!

hmsilva and braudpat, I am impressed.

 

For now I met the lisps which worked as follows:

We have Hatch, Polyline, a Block which has height attribute, Line and four MTexts in which is typed whatever we want.

 

The first lisp works on this rule:

Choose Hatch which Area you want to put in MText which you will select -> Select MText in which will be the Hatch's Area putted

 

The second lisp works on this rule:

Choose Polyline which Area you want to put in MText which you will select -> Select MText in which will be the Polyline's Area putted

 

The third lisp works on this rule:

Choose Line which Length you want to put in MText which you will select -> Select MText in which will be the Line's Length putted

 

 

The fourth lisp works on this rule:

Choose Block which Height you want to put in MText which you will select -> Select MText in which will be the Block's Height putted

 

 

And when I start this topic I thought about a lisp which works like these four.

But now the first time in my life I see lisp which creates its own MText, on the current Layer.

The idea to align this MText to the Line (in braudpat's 'SlopePC' lisp) is interesting. I am very satisfied.

 

 

0 Likes
Message 7 of 7

braudpat
Mentor
Mentor

 

Hello Damian

 

Please remind that I am NOT a Lisp/VLisp developper !

I have only MANY routines on stock ...

 

Gilles (a french Expert developper) is the author of a lot of routines that I am using every day

... So thanks again to Gilles !!

 

... But I am happy if you are happy ...

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes