Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
109 Posts
7 Kudos
Registered: ‎04-16-2011
Post 1 of 3

Showing tubes while drawing

188 Views, 2 Replies
05-27-2012 05:40 AM

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

Valued Mentor
267 Posts
8 Kudos
Registered: ‎09-22-2010
Post 2 of 3

Re: Showing tubes while drawing

05-29-2012 12:19 PM 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.
curtainwallBIM.blogspot.com
----------------------------------------------------------------------------------------------
Distinguished Contributor
109 Posts
7 Kudos
Registered: ‎04-16-2011
Post 3 of 3

Re: Showing tubes while drawing

05-29-2012 03:27 PM in reply to: jonmcfarlandWS

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

 

Regards

 

Thomas

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!