Author Topic: Rotating Text Parameter Error  (Read 749 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Rotating Text Parameter Error
« on: January 19, 2022, 05:49:00 PM »
I stumbled upon this routine, I changed it from looking at the UCS to the DVIEW option.

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rotating-leader-to-current-view/m-p/6934473#M350902

From what i have tested it seems like everything works except for the "text" or "dtext".

I get the following error:
Code: [Select]
Error: ActiveX Server returned an error: Parameter not optional
Code: [Select]
;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rotating-leader-to-current-view/m-p/6934473#M350902

;;; ------------------------------------------------------------------------

(defun c:zzr () (c:zZeroRotation)) ; Rotate Multileaders, Text, Mtext, Blocks to 0 relative to current UCS
(defun c:zZeroRotation (/ *error* AT:UCSAngle ang ss name ldr pts23 base refang)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SUBROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


  (defun *error* (msg)
    (and *AcadDoc* (vla-endundomark *AcadDoc*))
    (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
      (princ (strcat "\nError: " msg))
    )
  )


  (defun AT:UCSAngle (/)
    ;; Return current UCS angle
    ;; Alan J. Thompson, 04.06.10
    ((lambda (x) (atan (cadr x) (car x))) (trans (getvar 'UCSXDIR) 0 (trans '(0. 0. 1.) 1 0 T) T))
  )


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  (vl-load-com)

  (vla-startundomark
    (cond (*AcadDoc*)
          ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
    )
  )

  (if (ssget "_:A" '((0 . "INSERT,MTEXT,*LEADER,TEXT"))); changed to *LEADER - both regular and Multi
    (progn


;;      (setq ang (AT:UCSAngle))
(setq snapang (getvar "snapang"))
(command "UCS" "View")
(setvar "snapang" (- snapang (AT:UCSAngle)))


      (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*))
        (cond
          ((vl-position (setq name (vla-get-objectname x)) '("AcDbBlockReference" "AcDbText"))
            (vla-put-rotation x ang)
          )
          ((eq name "AcDbMText") (vla-put-rotation x 0.))
          ((eq name "AcDbText") (vla-put-rotation x 0.)) ;;; <<<<---- Error: ActiveX Server returned an error: Parameter not optional
          ((and (eq name "AcDbMLeader") (eq (vla-get-contenttype x) 2))
            (vla-put-textrotation x 0.)
          )
          ((eq name "AcDbLeader"); added another condition
            (setq
              ldr (vlax-vla-object->ename x); Leader entity
              pts23 ; defining points 2 & 3
                (cdr ; remove first one [arrow point]
                  (mapcar 'cdr ; remove 10's [leave coordinates only]
                    (vl-remove-if
                      '(lambda (x) (/= (car x) 10))
                      (entget ldr)
                    ); ...remove...
                  ); mapcar
                ); cdr & pts23
            ); setq
            (command "_.rotate" ldr ""
              (setq base (trans (car pts23) 0 1)); (trans)lated from WCS to current UCS
              "_reference" (angtos (setq refang (angle base (trans (cadr pts23) 0 1))) 2 8)
              (angtos (* (fix (+ (/ refang pi) 0.5)) pi) 2 8); nearer horizontal direction
            ); command
          ); Leader condition
        ); cond
      ); vlax-for
      (vla-delete ss)

    )
  )
  (*error* nil)
  (princ)
)

;;; ------------------------------------------------------------------------

I am sure i am missing something. Thanks for the help!
Civil3D 2020

CincyJeff

  • Newt
  • Posts: 89
Re: Rotating Text Parameter Error
« Reply #1 on: January 20, 2022, 12:36:26 PM »
Just a quick glance - does ang have a value?
(vla-put-rotation x ang)

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Rotating Text Parameter Error
« Reply #2 on: January 20, 2022, 04:04:12 PM »
MSTG007, I'm with CincyJeff. The (setq ang ....) is commented out. So it is likely failing in this section, not the one you pointed out:

          ((vl-position (setq name (vla-get-objectname x)) '("AcDbBlockReference" "AcDbText"))
            (vla-put-rotation x ang) ;;<<<<<<<<<<<<<<
          )

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Rotating Text Parameter Error
« Reply #3 on: January 20, 2022, 05:21:13 PM »
Thanks guys for the view. Always something i miss lol. I have removed the comment, the direct text and all seems to be working. The only new thing to me that appears, is now the Mleaders with Block Attributes are not matching the view.
Civil3D 2020