Author Topic: set distance by lisp in a dynamic block  (Read 4441 times)

0 Members and 1 Guest are viewing this topic.

Romero

  • Newt
  • Posts: 25
set distance by lisp in a dynamic block
« on: August 16, 2018, 12:08:46 AM »
Hi.
Maybe someone here in this forum can help me.
I'm trying to set the distance for a dynamic block of a single parameter; which is linear and is called Distance1.
I do not know what I'm doing wrong, but I can not do it and change the desired distance.
He helped me with the functions of Lee Mac, but something is wrong. Any help very similar, I will be completely grateful.


Code - Auto/Visual Lisp: [Select]
  1. (defun c: ddd (/ obj dd)    
  2.  
  3. (if (y (setq obj (car (entsel "\ ndynamic block:")              
  4. (setq dd (getdist "\ Length:"))))              
  5. (= "AcDbBlockReference" (vla- get-objectname (setq obj (vlax-esame-> vla-object obj))))              
  6. (=: vlax-true (vla-get-isdynamicblock obj))        
  7. )        
  8.  
  9. (LM: setdynpropvalue obj "Distance1" dd)    
  10. )    
  11.  
  12.  
  13. )
  14.  
  15.  
  16. (defun LM: setdynpropvalue (blk prp val)    
  17. (setq prp (strcase prp))    
  18.  
  19. (vl-some        '(lambda (x)            
  20. (if (= prp (strcase (vla-get-propertyname x)))                
  21. (progn                    
  22. (vla- put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))                    
  23. (cond (val) (t))                
  24. )            
  25. )        
  26. )        
  27. (vlax-invoke blk 'getdynamicblockproperties)     ) )

Dlanor

  • Bull Frog
  • Posts: 263
Re: set distance by lisp in a dynamic block
« Reply #1 on: August 16, 2018, 02:42:01 AM »
Your parentheses were a bit out, and there were spurious spaces and spelling mistakes in some activeX function names. Try this:

Code - Auto/Visual Lisp: [Select]
  1. (defun c: ddd (/ ent obj dd)    
  2.  
  3. (if (setq ent (car (entsel "\ndynamic block:"))); You are getting an entity here              
  4.   (setq dd (getdist "\nLength:"))
  5.   (if (and  (= "AcDbBlockReference" (vla-get-objectname (setq obj (vlax-ename->vla-object ent)))); You're converting to an object here. No spaces in function names
  6.             (= :vlax-true (vla-get-isdynamicblock obj))        
  7.       );end_and          
  8.     (LM: setdynpropvalue obj "Distance1" dd)    
  9.   );end_if    
  10. );end_if
  11. (princ)  
  12. );end_defun
  13.  

And compare it with your code.

steve.carson

  • Newt
  • Posts: 108
Re: set distance by lisp in a dynamic block
« Reply #2 on: August 16, 2018, 12:12:50 PM »
There is also an extra space in the LM:setdynpropvalue function.


Dlanor

  • Bull Frog
  • Posts: 263
Re: set distance by lisp in a dynamic block
« Reply #3 on: August 16, 2018, 12:29:09 PM »
There is also an extra space in the LM:setdynpropvalue function.

  :wideeyed: :nerdyembarassed:

steve.carson

  • Newt
  • Posts: 108
Re: set distance by lisp in a dynamic block
« Reply #4 on: August 16, 2018, 12:35:18 PM »
I meant function name. The code shows "LM: setdynpropvalue" when it should be "LM:setdynpropvalue".

Dlanor

  • Bull Frog
  • Posts: 263
Re: set distance by lisp in a dynamic block
« Reply #5 on: August 17, 2018, 07:07:57 AM »
I meant function name. The code shows "LM: setdynpropvalue" when it should be "LM:setdynpropvalue".

I know, I didn't see it hence the emoticons.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: set distance by lisp in a dynamic block
« Reply #6 on: August 17, 2018, 02:47:59 PM »
Looks like a double post...
Speaking English as a French Frog

ronjonp

  • Needs a day job
  • Posts: 7529
Re: set distance by lisp in a dynamic block
« Reply #7 on: August 17, 2018, 03:16:15 PM »
Looks like a double post...
Triple post .. on cadtutor too... ::)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC