Author Topic: Error: Automation Error. Cannot scale nonuniformly  (Read 1128 times)

0 Members and 1 Guest are viewing this topic.

damn

  • Mosquito
  • Posts: 15
Error: Automation Error. Cannot scale nonuniformly
« on: March 01, 2021, 02:04:15 AM »
I'm stumped on this error.   In a new drawing session if I open Template "C" and run  a layout generator routine I get this error.  If I open Template "A" and rerun the routine it works.  If Template "A" has been open at any stage during the session it will work.  I've pinpointed down to a key viewport that is rezoomed on ea layout.  I Haven't written the following code and whilst it mostly works well much of it is poorly documented.  I've also pinpointed the code down to this line.  (vla-transformby obj mat)

I realise that's not much help.  What possibly could opening another template introduce to prevent the error?

Code expanded.....

Code - Auto/Visual Lisp: [Select]
  1. (foreach obj
  2.            (vlax-invoke
  3.              (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  4.              'copyobjects
  5.              lst
  6.              (vla-get-block
  7.                alay
  8.              )
  9.            )
  10. ;;; Code below crashes if Telstra template has not been opened
  11.     (vla-transformby obj mat)
  12.  
  13.   )


EDIT (John): Added code tags.
« Last Edit: March 01, 2021, 03:11:49 PM by John Kaul (Se7en) »

BIGAL

  • Swamp Rat
  • Posts: 1411
  • 40 + years of using Autocad
Re: Error: Automation Error. Cannot scale nonuniformly
« Reply #1 on: March 01, 2021, 08:16:36 PM »
telstra your in AUS

To many unknowns you have 3 variables with no idea of values.

Explain what it is your trying to do.
A man who never made a mistake never made anything

damn

  • Mosquito
  • Posts: 15
Re: Error: Automation Error. Cannot scale nonuniformly
« Reply #2 on: March 02, 2021, 05:37:52 PM »
Hi Al,  yeah I'm Aus.  In short the code is part of a function creating layouts base on the number of frames in the drawing.  I haven't tried to figure what this part of the code does as up till now it worked as I always used template A 1st.  One of my colleagues discovered when they jumped straight into template C and at 1st I couldn't replicate their problem.

This part of the function zooms on the Key viewport in on the current frame relative to the created to layout and from what I can read it try to sort draw order.   Code elaborated, sorry still poorly documented.  I realise this probably won't  help.  I was hoping the scale nonuniformly was common bug.

Code - Auto/Visual Lisp: [Select]
  1. (defun _copyNTSnbn      (ob vp lay / acobj acdoc aclay ascc)
  2.         acdoc (vla-get-ActiveDocument acobj)
  3.         aclay (vla-get-layouts acdoc)
  4.         ascc  (vla-get-selectionsets acdoc)
  5.         alay (vla-item (vla-get-layouts acdoc) lay)
  6.   )
  7.     acdoc
  8.     alay
  9.   )
  10.  
  11.   (setq lst (list ob))
  12.  
  13.   (vla-put-mspace acdoc :vlax-true)
  14.  
  15.  
  16.   (setq mat
  17.          (vlax-tmatrix
  18.            (append
  19.              (mapcar
  20.                '(lambda (a b)
  21.                   (append (mapcar '- (trans (trans a 0 2) 2 3) org) (list b))
  22.                 )
  23.                '(
  24.                  (1.0 0.0 0.0)
  25.                  (0.0 1.0 0.0)
  26.                  (0.0 0.0 1.0)
  27.                 )
  28.                (setq org (trans (trans '(0.0 0.0 0.0) 0 2) 2 3))
  29.              )
  30.              '((0.0 0.0 0.0 1.0))
  31.            )
  32.          )
  33.   )
  34.  
  35.   (foreach obj
  36.            (vlax-invoke
  37.              (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  38.              'copyobjects
  39.              lst
  40.              (vla-get-block
  41.                alay
  42.              )
  43.            )
  44. ;;; Code below crashes if Telstra template has not been opened
  45.     (vla-transformby obj mat)
  46.  
  47.   )
  48.  
  49.   (vla-put-mspace acdoc :vlax-false)
  50.   (setvar "clayer" layerNTSGRID)
  51.  
  52.   (setq new (ssget "L"))
  53.   (if (setq eName (ssname new 0))
  54.     (progn
  55.       (vla-getboundingbox (vlax-ename->vla-object eName) 'mn 'mx)
  56.       (vl-cmdf "._rectang" (vlax-safearray->list mn) (vlax-safearray->list mx)))
  57.     )
  58.   (entdel eName)
  59.  
  60.   (setq pline (vlax-ename->vla-object (ssname (ssget "L") 0)))
  61.   (setq outerLoop (vlax-make-safearray vlax-vbObject '(0 . 0)))
  62.   (vlax-safearray-put-element outerLoop 0 pline)
  63.  
  64.   (setq hatch (vla-AddHatch (vla-get-block alay) acHatchPatternTypePreDefined "ANSI31" :vlax-True))
  65.   (vla-appendouterloop hatch outerLoop)
  66.   (vla-put-color hatch acMagenta)
  67.   (vla-evaluate hatch)
  68.   (vla-delete pline)
  69. )


EDIT (John): Added code tags.
« Last Edit: March 02, 2021, 05:46:34 PM by John Kaul (Se7en) »