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

Set UCS by XYZ coordinates of two points in LISP

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
6409 Views, 5 Replies

Set UCS by XYZ coordinates of two points in LISP

Hi,

 

I am struggling with UCS command in AutoLISP. I am repositioning UCS by shifting its origin to start of a LINE and aligning X-axis to the LINE itself. The point on XY plane can be choosen manually. This routine should make a user choose a line and then reposition UCS accordingly.

 

(setq current_line (entsel "\n Select the LINE: "))

(setq point1_wcs (cdr (assoc 10 (entget (car current_line))))); one end of the line in WCS

(setq point1_ucs (trans point1_wcs 0 1)) ; same end of the line in UCS


(setq point2_wcs (cdr (assoc 11 (entget (car current_line))))); another end of the line in WCS

(setq point2_ucs (trans point1_wcs 0 1)) ; same end of the line in UCS

 

(command "ucs" point1_ucs pause pause)

 

I figured out how to pass origin point to LISP but can't seem to figure out what to pass as a second argument. I would assume it must be a second point from the line but whenever I pass coordinates of the other end of the line (either point2_wcs or point2_ucs), X axis is not aligned to the line.

 

Is there a way to pass a point based on X,Y,Z coordinates to UCS command.

 

Thank you for your help.

5 REPLIES 5
Message 2 of 6
hmsilva
in reply to: Anonymous

Change

(setq point2_ucs (trans point1_wcs 0 1)) ; same end of the line in UCS

to

(setq point2_ucs (trans point2_wcs 0 1)) ; same end of the line in UCS

and

(command "ucs" point1_ucs pause pause)

to

(command "ucs" "_3p" point1_ucs point2_ucs pause)

 

Henrique

EESignature

Message 3 of 6
Lee_Mac
in reply to: Anonymous

Here is some commented code to help you:

 

(defun c:ucsl ( / ent enx )
    (if ;; If the following expressions return a non-nil value
        (and ;; If ALL of the following expressions return a non-nil value
            (setq ent (car (entsel "\nSelect Line: "))) ;; Prompt the user to select a line
            (= "LINE" (cdr (assoc 0 (setq enx (entget ent))))) ;; Is it a line?
        ) ;; end AND
        (command ;; Evaluate the following expressions at the command-line
            "_.ucs" ;; Invoke the UCS command
            "_non"  ;; Ignore Object Snap for the following point
            (trans (cdr (assoc 10 enx)) 0 1) ;; Pass the start point of the line (in UCS)
            "_non"  ;; Ignore Object Snap for the following point
            (trans (cdr (assoc 11 enx)) 0 1) ;; Pass the end point of the line (in UCS)
            "\\" ;; Pause for user input
        ) ;; end COMMAND
    ) ;; end IF
    (princ) ;; Suppress the return of the last evaluated expression
) ;; end DEFUN
Message 4 of 6
Anonymous
in reply to: hmsilva

Thank you, Henrique. I didn't know about "_3p". It works now.

Message 5 of 6
hmsilva
in reply to: Anonymous

You're welcome!
Glad I could help

Henrique

EESignature

Message 6 of 6
serkancavuslar
in reply to: hmsilva

bisector 2 surface joint

 

see 1 face see1 face see and joint see final axle (axis)

 

I think this is the solution

 

Please follow the attachment.

 

 

Serkan ÇAVUŞLAR

 

Serkan ÇAVUŞLAR
CplCAD / Türkiye
Tags (1)

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

Post to forums  

Autodesk Design & Make Report

”Boost