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

Showing tubes while drawing

2 REPLIES 2
Reply
Message 1 of 3
Thomas.l
371 Views, 2 Replies

Showing tubes while drawing

Hi all,

 

I am working on a lisp that automaticaly draws some tubes and fittings.

First the user has to select the block where the tubes start and then he selects where the tubes has to end.

Herefor i whrote this lisp (you can see an example in the atached file):

 

(defun c:test ()

   ;;------------=={ Set Dynamic Property Value }==--------------;;
;;                                                            ;;
;;  Modifies the value of a Dynamic Block Property            ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  block - VLA Dynamic Block Reference Object                ;;
;;  prop  - Dynamic Block Property Name                       ;;
;;  value - New value for Property                            ;;
;;------------------------------------------------------------;;
;;  Returns: Value property was set to, else nil              ;;
;;------------------------------------------------------------;;

(defun LM:SetDynamicPropValue ( block prop value )
    (setq prop (strcase prop))
    (vl-some
        (function
            (lambda ( _prop )
                (if (eq prop (strcase (vla-get-propertyname _prop)))
                    (progn
                        (vla-put-value _prop
                            (vlax-make-variant value
                                (vlax-variant-type (vla-get-value _prop))
                            )
                        )
                        value
                    )
                )
            )
        )
        (vlax-invoke block 'GetDynamicBlockProperties)
    )
)

  ;***************************************************************
  ;converts radians to degrees
  ;***************************************************************

  (defun raddeg (rad)
    (* (/ rad (* 2 pi)) 360 )
    )
  (defun invoegenkokers (pt1 pt2)

  ;***************************************************************
  ;insert tubes
  ;***************************************************************

  
  (setq len (distance pt1 pt2)
	angrad (angle pt1 pt2)
	angdeg (raddeg angrad)
	lenk 3000
	koker "koker 80"
	mofspir "mof spiraalkoker 80"
	)

  (while (> len lenk)
    (command "insert" koker pt1 "1" "1" angdeg)
    (setq pt1 (polar pt1 angrad lenk))
    (command "insert" mofspir pt1 "1" "1" angdeg)
    (setq len (- len lenk))
    )
  (command "insert" koker pt1 "1" "1" angdeg)
  (LM:SetDynamicPropValue (vlax-ename->vla-object (entlast)) "distance1" len)
  )

  ;*******************************************************
  ;Determin points for tubes
  ;*******************************************************

  
  (setq bblock (car (entsel))
	pt1 (cdr (assoc 10 (entget bblock)))
	pt2 (getpoint pt1)
	angrad (angle pt1 pt2)
	pt1 (polar pt1 angrad 92) 
	)

  (LM:SetDynamicPropValue (vlax-ename->vla-object bblock) "angle" (- angrad pi))

  (setvar "osmode" 0)
  
  (invoegenkokers pt1 pt2)

  (setvar "osmode" 39)
  
  )

  

 

But I am not completely hapy with it.

Is it posible to show the user how the tubes gow befor chozing the second point?

(A litle bit like when you stretch a dynamic block where you can see how the object whil look like while preforming the stretch action).

 

Regards

 

Thomas

2 REPLIES 2
Message 2 of 3
jonmcfarlandGY
in reply to: Thomas.l

Thomas,

 

If you wrote the routine, then why is " Author: Lee Mac, Copyright © 2010 - www.lee-mac.com " in the code?

Jon

Please select "Accept as Solution" if your question was answered
Message 3 of 3
Thomas.l
in reply to: jonmcfarlandGY

That peace of the routine comes directly from his site and i wanted to give him credit for it.

 

Regards

 

Thomas

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

Post to forums  

Autodesk Design & Make Report

”Boost