Jump to content

VLA-ROTATE in while


Arash-ET

Recommended Posts

Hi every one i have a problem with my lisp does any one here can help me this is my problem:

i want to rotate my object with vla-rotate in while but when you run this program the line will rotate to much please help

(DEFUN C:TEST ()
  ;DRAW PLINE
  (SETQ P1 (GETPOINT "\nSpecify first point: ")
        P2 (POLAR P1 0 5.0)
        P3 (POLAR P2 (/ PI 2.0) 1.0)
        P-LST (APPLY 'APPEND (LIST P1 P2 P3))
        P-LST (VLAX-SAFEARRAY-FILL (VLAX-MAKE-SAFEARRAY VLAX-VBDOUBLE (CONS 0 (- (LENGTH P-LST) 1))) P-LST)
        )
  (SETQ OBJ (VLA-ADDPOLYLINE (VLA-GET-MODELSPACE (VLA-GET-ACTIVEDOCUMENT (VLAX-GET-ACAD-OBJECT))) P-LST))
  ;VLA-ROTATE
  (PRINC "\nSpecify second point: ")
  (WHILE (MEMBER (CAR (SETQ GR (GRREAD T 15 0))) '(5 2))
    (IF (LISTP (CADR GR))
      (VLA-ROTATE OBJ (VLAX-3D-POINT P1) (ANGLE P1 (CADR GR)))
      )
    (IF (= (CADR GR) 15)
      (SETVAR 'ORTHOMODE (- 1 (GETVAR 'ORTHOMODE)))
      )
    )
  )

Link to comment
Share on other sites

Rotate command does like the grread or am I missing something, your drawing a "L" then rotating it. You could certainly do a dummy xline etc  line from p1 to wanted angle pick point  then use that to rotate (entlast). 

Link to comment
Share on other sites

3 minutes ago, BIGAL said:

Rotate command does like the grread or am I missing something, your drawing a "L" then rotating it. You could certainly do a dummy xline etc  line from p1 to wanted angle pick point  then use that to rotate (entlast). 

Hi Bigal actually I want to draw "L" for user but user must specify the angle of "L" but i want the user see the object and rotate.

I know i have simple option like ask the angle from user in first place and then draw "L" but i like user able to see the object and after that specify the angle of it

Actually i use this part as well

(SETQ SS (SSADD (VLAX-VLA-OBJECT->ENAME OBJ)))
  (WHILE SS
    (SETQ ANG (ACET-SS-DRAG-ROTATE SS (TRANS P1 0 1) "\nSpecify second point: "))
    (IF (= (CADR GR) 15)
      (SETVAR 'ORTHOMODE (- 1 (GETVAR 'ORTHOMODE)))
      )
    (SETQ SS NIL)
    )

but it have a little problem ACET-SS-DRAG-ROTATE keep first object and create illustrator of first object

Link to comment
Share on other sites

I don't know about showing the object itself but you can show the rotation angle.

 

(defun C:TEST (/ drawing util MS P1 P2 P3 P-LST OBJ ANG)
  (vl-load-com)
  (setq drawing (vla-get-activedocument (vlax-get-acad-object))
        util (vla-get-utility drawing)
        MS (vla-get-modelspace drawing)
        P1 (getpoint "\nSpecify first point: ")
        P2 (polar P1 0 5.0)
        P3 (polar P2 (/ PI 2.0) 1.0)
        P-LST (apply 'append (list P1 P2 P3))
        P-LST (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (lenght P-LST) 1))) P-LST) ;not needed in briscad
        OBJ (vla-addpolyline MS P-LST)
        ang (vla-getangle util p1 "\nRotation Angle: ") 
  )
  (vla-rotate OBJ P1 ang)  
  (princ)
)

 

  • Like 1
Link to comment
Share on other sites

16 hours ago, mhupp said:

I don't know about showing the object itself but you can show the rotation angle.

 

(defun C:TEST (/ drawing util MS P1 P2 P3 P-LST OBJ ANG)
  (vl-load-com)
  (setq drawing (vla-get-activedocument (vlax-get-acad-object))
        util (vla-get-utility drawing)
        MS (vla-get-modelspace drawing)
        P1 (getpoint "\nSpecify first point: ")
        P2 (polar P1 0 5.0)
        P3 (polar P2 (/ PI 2.0) 1.0)
        P-LST (apply 'append (list P1 P2 P3))
        P-LST (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (lenght P-LST) 1))) P-LST) ;not needed in briscad
        OBJ (vla-addpolyline MS P-LST)
        ang (vla-getangle util p1 "\nRotation Angle: ") 
  )
  (vla-rotate OBJ P1 ang)  
  (princ)
)

 

actually I found a solution for this:

(DEFUN C:TEST ()
  ;DRAW PLINE
  (SETQ P1 (GETPOINT "\nSpecify first point: ")
        P2 (POLAR P1 0 5.0)
        P3 (POLAR P2 (/ PI 2.0) 1.0)
        P-LST (APPLY 'APPEND (LIST P1 P2 P3))
        P-LST (VLAX-SAFEARRAY-FILL (VLAX-MAKE-SAFEARRAY VLAX-VBDOUBLE (CONS 0 (- (LENGTH P-LST) 1))) P-LST)
        )
  (SETQ OBJ (VLA-ADDPOLYLINE (VLA-GET-MODELSPACE (VLA-GET-ACTIVEDOCUMENT (VLAX-GET-ACAD-OBJECT))) P-LST))
  (VL-CMDF "._FILLET" "_p" "_r" 0.3 (VLAX-VLA-OBJECT->ENAME OBJ))
  ;VLA-ROTATE
  (PRINC "\nSpecify second point: ")
  (SETQ ANG-TEMP 0)
  (WHILE (MEMBER (CAR (SETQ GR (GRREAD T 15 0))) '(5))
    (IF (LISTP (CADR GR))
      (PROGN
        (SETQ ANG (ANGLE P1 (CADR GR)))
        (VLA-ROTATE OBJ (VLAX-3D-POINT P1) (- ANG ANG-TEMP))
        )
      )
    (SETQ ANG-TEMP ANG)
    )
  )

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...