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

using vla-put-linearscalefactor

2 REPLIES 2
Reply
Message 1 of 3
CNCjeff
475 Views, 2 Replies

using vla-put-linearscalefactor

I'm okay with Lisp but not so good with the Active X commands. This routine should be easy
but I keep getting and error saying:

error: bad argument type: VLA-OBJECT ((-1 . ) (0 . "DIMENSION") ... etc


Here is my code:

;*********************************************************

; dls changes the linear scale factor of all dimensions to 4.0

;**********************************************************

(defun c:dls(/ dims dimobj c)

(vl-load-com)

(setq c -1)

(setq dims (ssget "x" '((0 . "DIMENSION"))))

(repeat (sslength DIMS)

(setq c (1+ c))

(setq dimobj (entget (ssname dims 0)))

(vla-put-linearscalefactor dimobj 4.0)

)

)

Any help would be great
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: CNCjeff


Hi,

 

You have to convert an entity name label into an
ActiveX object, in order to be able to apply properties and methods on it. The
conversion is done using (vlax-ename->vla-object ...)
function. It takes an entity name type of data and returns an ActiveX object
type of data. Please note also that in  your original code you don't test
if the selection set exists (an empty selection set would trigger an error
because (sslength ...) argument can't be nil) and also note that you don't
increment (or decrement, like in my example) your
size=3>c
index, so your code would pass on the first element of
the selection set for as many times as the number of the items in the
selection set. Here is another function, modified and corrected. Try to compare
the two and see the errors and the differences:

 

;;;=================================

(defun c:dls ( / dims index)
 
(vl-load-com)
  (if (setq dims (ssget "X" '((0 .
"DIMENSION"))))
    (repeat (setq index (sslength
dims))
     
(vla-put-linearscalefactor
       
(vlax-ename->vla-object
         
(ssname dims (1- index))
       
)
       
4.0
      )    

      (setq (index (1-
index)))
    )
  )
 
(princ)
)

;;;=================================

 

HTH


--
Humans are born with a wide horizon.
As time goes by, the
horizon narrows and
narrows, until it becomes a point of view.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I'm
okay with Lisp but not so good with the Active X commands. This routine should
be easy but I keep getting and error saying: error: bad argument type:
VLA-OBJECT ((-1 . ) (0 . "DIMENSION") ... etc Here is
my code: ;********************************************************* ; dls
changes the linear scale factor of all dimensions to 4.0
;********************************************************** (defun c:dls(/
dims dimobj c) (vl-load-com) (setq c -1) (setq dims (ssget "x" '((0 .
"DIMENSION")))) (repeat (sslength DIMS) (setq c (1+ c)) (setq dimobj (entget
(ssname dims 0))) (vla-put-linearscalefactor dimobj 4.0) ) ) Any help would be
great
Message 3 of 3
CNCjeff
in reply to: CNCjeff

Thanks. I had to change a couple of parentheses but everything was there for me.

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

Post to forums  

Autodesk Design & Make Report

”Boost