PDA

View Full Version : Edited Bored LISP



Hippe013
23rd Jul 2010, 08:28 pm
I recieved a lisp from Lee Mac. Bored.lsp

Code is as follows:



(defun c:bored ( / cir cnt gr lst n d )
;; © Lee Mac 2010
(setq lst (list (getvar 'viewctr) (getvar 'viewctr)) cnt 0)

(while (eq 5 (car (setq gr (grread nil 13 0))))
(redraw)
(setq cir nil n 0 lst (append lst (list (last lst) (cadr gr)))
cnt (1+ cnt))

(if (< 100 cnt) (setq lst (cddr lst)))

(repeat 50
(setq d (/ (distance (car lst) (last lst)) 4.))
(repeat 4
(setq cir (cons (polar (car lst) (* (setq n (1+ n)) (/ (* pi 2) 50)) d) cir))
(setq d (/ d 2.))
)
)
(grvecs (append (list (rem (/ cnt 100) 255)) lst cir))
)
(redraw)
(princ)
)


Now, I have edited it to drag around an object, code as follows:


(defun c:bored2 ( / )
;; © Lee Mac 2010
;Edit by Hippe 2010
(setq obj (vlax-ename->vla-object (car (entsel))))
(setq ins (vlax-get-property obj 'InsertionPoint))
(setq lst (list (getvar 'viewctr) (getvar 'viewctr)) cnt 0)

(while (eq 5 (car (setq gr (grread nil 13 0))))
(redraw)
(setq cir nil n 0 lst (append lst (list (last lst) (cadr gr)))
cnt (1+ cnt))

(if (< 100 cnt) (setq lst (cddr lst)))

;(repeat 50
; (setq d (/ (distance (car lst) (last lst)) 4.))
;(repeat 4
; (setq cir (cons (polar (car lst) (* (setq n (1+ n)) (/ (* pi 2) 50)) d) cir))
; (setq d (/ d 2.))
; )
;)
(grvecs (append (list (rem (/ cnt 100) 255)) lst cir))
(vlax-put-property obj 'InsertionPoint (vlax-3d-point (nth 0 lst)))
(vla-update obj)

)
(redraw)
(vlax-put-property obj 'InsertionPoint ins)
(vlax-release-object obj)
(princ)
)

This code should work with any object that has an Insertion Point Property.

Now my question is: This works with a piece of single line text with a left justification, but doesn't seem to work with a Middle Center Justification. Can anyone see why it doesn't work?

Thanks in advance.

hippe013

P.S. Lee Mac... thanx again, fun stuff! :P

Lee Mac
23rd Jul 2010, 08:34 pm
Hint: Read up on vla-get-insertionPoint for text.

Hippe013
23rd Jul 2010, 09:04 pm
Thanks for the quick reply!

I've tried using the TextAlignmentPoint property instead and it works. Though my question is that why is that I am not able to move the object by changing the InsertionPoint property?

Lee Mac
23rd Jul 2010, 09:07 pm
I've tried using the TextAlignmentPoint property instead and it works. Though my question is that why is that I am not able to move the object by changing the InsertionPoint property?

Did you read the Dev Help Notes?

Hippe013
23rd Jul 2010, 09:09 pm
Yes, I am in the process of reading them now. I am no stranger to the help files! :) Though I am having a hard time finding where they explain the both.

Hippe013
23rd Jul 2010, 09:16 pm
Found it! Thanks. :oops:


For the readers:

TextAlignmentPoint
Text: This property will be reset to 0, 0, 0 and will become read-only when the Alignment (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Civil% 203D%20Land%20Desktop%20Companion%202009\help\acad auto.chm::/idh_alignment.htm) property is set to acAlignmentLeft. To position text whose justification is left, fit, or aligned, use the InsertionPoint (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Civil% 203D%20Land%20Desktop%20Companion%202009\help\acad auto.chm::/idh_insertionpoint.htm) property.

InsertionPoint
Text: This property is read-only except for text whose Alignment (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Civil% 203D%20Land%20Desktop%20Companion%202009\help\acad auto.chm::/idh_alignment.htm) property is set to acAlignmentLeft, acAlignmentAligned, or acAlignmentFit. To position text whose justification is other than left, aligned, or fit, use the TextAlignmentPoint (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Civil% 203D%20Land%20Desktop%20Companion%202009\help\acad auto.chm::/idh_textalignmentpoint.htm) property.

Hippe013
23rd Jul 2010, 09:53 pm
Note:

(vlax-property-available-p obj 'InsertionPoint T)

With the obj (text object) being Left justified or Middle Center justfied vlax-property-available-p (with check-modify set to T) will still return True. Which it seems to me that it shouldn't... any ideas about this?

Lee Mac
23rd Jul 2010, 10:00 pm
Yes of course it will return T, the properties are independent of each other and dependent on the Object.

Just check the Alignment to see which to use.

Hippe013
24th Jul 2010, 12:36 am
I would have to agree and checking the alignment to see which to use is obviously the route to go. Though it would stand to reason that if one property becomes read-only dependent on the value of the alignment that vlax-property-available-p would pick up on that fact that the value has now become read-only and return nil. Wouldn't you agree Lee?

Lee Mac
24th Jul 2010, 02:01 am
It doesn't become read-only - it just has no effect on position.