VLA-Rotate Error

VLA-Rotate Error

Anonymous
Not applicable
1,380 Views
4 Replies
Message 1 of 5

VLA-Rotate Error

Anonymous
Not applicable

I'm attempting to create a block  from selected objects then rotate that block a specific angle. My code is below.  When running the program it errors out at "(vla-rotate block ipt VPAng)" VPAng is the value I'd like to rotate the block by. IPT is the insertion point of the scaled block. When running with "IPT" I get this error:

 

"lisp value has no coercion to VARIANT with this type: (29605.1 15304.3 0.0)
 lisp value has no coercion to VARIANT with this type: (29605.1 15304.3 0.0)"

 

When running with "BPT" as the basepoint I get this error:

 

"Automation Error: Description Was Not Provided"

 

Here's my code:

(defun MakeBlock (/ ss bpt name) ;ctrl+shift N
(prompt "\nSelect features for block")
(if (and (setq ss (ssget W)
                         bpt (getpoint "\nSelect Block Base Point")
                         ipt (polar Entpnt (* 1.5 pi) 2000)
                         name (getstring T "\nName: ")
                         yscale ScFac
               )
               (command "_.-BLOCK" name "_non" bpt
                                    ss "" "_.oops" "_.-INSERT"
                                    name "_S" 1 "_R" 0
                                    "_non" ipt
                )
    )
    (princ)
)
(setq block (entget (entlast))
          block (vlax-ename->vla-object (cdr (car block)))
)
(vlax-put-property block "YEffectiveScaleFactor" yscale)
(vlax-put-property block "YScaleFactor" yscale)
(vla-rotate block ipt VPAng)
)

 

Can you tell me why it breaks in both cases and what needs to be done to correct it?

 

Thanks, Brad

0 Likes
Accepted solutions (1)
1,381 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Accepted solution

I have found the issue. When using "IPT" as the basepoint of rotation, the value needs to be a variant rather than 3d point. The correction is below.

 

(vla-rotate block (vlax-3D-point ipt) VPAng)

Message 3 of 5

ronjonp
Mentor
Mentor

If you want to pass a point use vlax-invoke like so:

(setq block (vlax-ename->vla-object (car (entsel))))
(vlax-invoke block 'rotate (getpoint) pi)
0 Likes
Message 4 of 5

ronjonp
Mentor
Mentor

FWIW, your 'AND' statement could return T even if a null value is within .. see example:

;; Returns T
(and (setq a 1
	   b 2
	   c nil
	   d 4
     )
)
;; Returns nil
(and (setq a 1) (setq b 2) (setq c nil) (setq d 4))

Also, I don't see where 'scfac' is ever set?

0 Likes
Message 5 of 5

Anonymous
Not applicable

"ScFac" was set much earlier in the program. It's much larger than what is shown here. Thanks for the heads up on the And function.

0 Likes