Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
Thomas.l
Posts: 109
Registered: ‎04-16-2011
Message 1 of 9 (400 Views)
Accepted Solution

Selecting block parameter whit lisp

400 Views, 8 Replies
04-26-2012 11:26 PM

Hi

 

I am working on a lisp routine that automaticaly inserts a parameter in a block and then ads a stretch command to it. But the problem is that for the stretch command u need to select the drawn parameter. So my plan was to get the name of this parameter (car (entsel)) and feet it to my lisp program. But when i do that it doesn't work because autocad demands a parameter. 

 

Hope somebody can help me whit this problem

 

Regards

 

Thomas

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 2 of 9 (398 Views)

Re: Selecting block parameter whit lisp

04-27-2012 12:00 AM in reply to: Thomas.l

Thomas.l wrote:

Hi

 

I am working on a lisp routine that automaticaly inserts a parameter in a block and then ads a stretch command to it. But the problem is that for the stretch command u need to select the drawn parameter. So my plan was to get the name of this parameter (car (entsel)) and feet it to my lisp program. But when i do that it doesn't work because autocad demands a parameter. 

 

Hope somebody can help me whit this problem

 

Regards

 

Thomas


 

Look into GetDynamicBlockProperties method

 

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 9 (392 Views)

Re: Selecting block parameter whit lisp

04-27-2012 12:40 AM in reply to: Thomas.l

Try something like this

(setq propname "Wall Height distance") ;<-- property name

(setq propval 1200.0);<-- propert value of double

 (if (setq ss (ssget "_:S" '((0 . "INSERT")(2 . "`*U*,*"))))   ;<-- to change dynamic blocks

  (progn

;get vla-object selected

 (setq blkobj (vlax-ename->vla-object (ssname ss 0)))  

;retrieve desired property list

         (setq proplst (vl-remove-if-not '(lambda (x) (eq (vla-get-PropertyName x) propname ))  

     (vlax-invoke blkobj 'getdynamicblockproperties)))  

;get dynamic property we need 

    (setq prop (car proplst))    

;set desired property value to this property    

     (vla-put-value prop (vlax-make-variant propval 5)) ;<-- 5 is for double value, see Help file

      (vla-update blkobj);<-- update selected block

  )    

   )

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
Thomas.l
Posts: 109
Registered: ‎04-16-2011
Message 4 of 9 (389 Views)

Re: Selecting block parameter whit lisp

04-27-2012 12:53 AM in reply to: Hallex

wel that is a piece of interesting code.

But it isn't exactly what i am looking for.

I simply want to be able to ad a stretch action to a stretch parameter whitout having to quite my lisp routine.

 

Regards

 

Thomas

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 5 of 9 (387 Views)

Re: Selecting block parameter whit lisp

04-27-2012 01:03 AM in reply to: Thomas.l

Thomas.l wrote:

wel that is a piece of interesting code.

But it isn't exactly what i am looking for.

I simply want to be able to ad a stretch action to a stretch parameter whitout having to quite my lisp routine.

 

Regards

 

Thomas



Share your code then we'll  incorporate the same method on your routine

 

Distinguished Contributor
Thomas.l
Posts: 109
Registered: ‎04-16-2011
Message 6 of 9 (385 Views)

Re: Selecting block parameter whit lisp

04-27-2012 01:12 AM in reply to: pbejse

This should give you the idea

 

(setq ang 0)

(defun c:az ()
  (setq pt1 (getpoint "define insertion point:")
	pt2 (polar pt1 (/ (* ang 2 pi) 360) 100))
  (command "bparameter" "linear" pt2 pt1 "500,0" "1")
  (command "baction")
  )

(defun c:aq ()
  (setq ang (+ ang 1))
  (command "bvstate" "set" ang))

 these functions work for block in attachemend when opend in block editor.

 

And thank you both for helping!

 

 

Regards

 

Thomas

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 7 of 9 (377 Views)

Re: Selecting block parameter whit lisp

04-27-2012 03:21 AM in reply to: Thomas.l

Thomas.l wrote:

This should give you the idea

 

 these functions work for block in attachemend when opend in block editor.

 

And thank you both for helping!

 Regards

 

Thomas


Try this way to select the parameter

 

(defun c:az ()
  (setq pt1 (getpoint "define insertion point:")
 pt2 (polar pt1 (/ (* ang 2 pi) 360) 100)
  )
  (command "bparameter" "linear" pt2 pt1 "500,0" "1")
  (command "baction" (nentselp pt1)) ;<--- you do the rest
)

Distinguished Contributor
Thomas.l
Posts: 109
Registered: ‎04-16-2011
Message 8 of 9 (368 Views)

Re: Selecting block parameter whit lisp

04-27-2012 06:05 AM in reply to: pbejse

Thank you very much that was exactly what i was looking foor.

I realy don't know how i could mis that.

 

Regards Thomas

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 9 of 9 (365 Views)

Re: Selecting block parameter whit lisp

04-27-2012 06:22 AM in reply to: Thomas.l

Thomas.l wrote:

Thank you very much that was exactly what i was looking foor.

I realy don't know how i could mis that.

 

Regards Thomas


You're welcome

Glad i could help

 

Cheers

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community