Author Topic: Error in vlax-3d-point  (Read 2143 times)

0 Members and 1 Guest are viewing this topic.

@_Bilal

  • Mosquito
  • Posts: 19
Error in vlax-3d-point
« on: March 05, 2018, 04:22:37 PM »
Hello,

Could some one help me to fix this error or explain to me why I get this error
"Error: Automation Error. UCS X axis and Y axis are not perpendicular" when
runing the below routine, noting that the the 2 segments are perpendicular.
Code - Auto/Visual Lisp: [Select]
  1. (defun ucsadd (ORg Xpt Ypt NAME / acaddoc_obj ucs_obj item)
  2.  
  3.  
  4. ;; V^V
  5. ;; Cross product of two vectors
  6. (defun v^v (u v)
  7.   (list (- (* (cadr u) (caddr v)) (* (caddr u) (cadr v)))
  8.         (- (* (caddr u) (car v)) (* (car u) (caddr v)))
  9.         (- (* (car u) (cadr v)) (* (cadr u) (car v)))
  10.   )
  11. );; Endof//v^v
  12.  
  13.  
  14.  
  15. ;; Calculate the yptp which is perpendicular to segment Org and Xpt
  16. ;; u and v vectors
  17.   (setq u (list (- (car Xpt) (car ORg)) (- (cadr Xpt) (cadr ORg)) (- (caddr Xpt) (caddr ORg))))
  18.   (setq v (list (- (car Ypt) (car ORg)) (- (cadr Ypt) (cadr ORg)) (- (caddr Ypt) (caddr ORg))))
  19.   (setq z (v^v u v));; calculate z vector
  20.   (setq Yptp (v^v z u))
  21.  
  22.  
  23. ;;;Start adding UCS
  24.   (setq ucs_obj (vla-get-UserCoordinateSystems acaddoc_obj))
  25.   (setq item (vla-add ucs_obj
  26.                 (vlax-3d-point org) ;;origin
  27.                 (vlax-3d-point Xpt) ;;x axis point
  28.                 (vlax-3d-point Yptp) ;;y axis point
  29.                 name;;name
  30.              ) ;_ end of vla-add
  31.   ) ;_ end of setq
  32.   (princ)
  33. );; Endof//ucsadd

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: Error in vlax-3d-point
« Reply #1 on: March 05, 2018, 05:09:50 PM »
Xpt is in WCS and Yptp is relative to origin.
Change this line
Code: [Select]
(setq Yptp (mapcar '+ org (v^v z u)))

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Error in vlax-3d-point
« Reply #2 on: March 05, 2018, 05:12:34 PM »
Try changing this line :

Code - Auto/Visual Lisp: [Select]
  1. (setq Yptp (v^v z u))
  2.  

To this :

Code - Auto/Visual Lisp: [Select]
  1. (setq Yptp (mapcar '+ ORg (v^v z u)))
  2.  

Note that your Yptp in your code is vector, and you need point at position of ORg + vector...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

@_Bilal

  • Mosquito
  • Posts: 19
Re: Error in vlax-3d-point
« Reply #3 on: March 05, 2018, 05:33:46 PM »
Thank you very much Ribarm and Stefan

I changed this line, the routine and i get accurate result
I understand where was my fault
thanks again