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

Using '(' and ')' characters in vla-put-CanonicalMediaName

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
GoldenEye15
1591 Views, 6 Replies

Using '(' and ')' characters in vla-put-CanonicalMediaName

I'm creating Named Page Setups through LISP and vla-put-CanonicalMediaName doesn't seem to accept papersizes if they have brackets/parenthesis characters in their names. The paper size I'm trying to set does exist and I have tried escaping the brackets with a backslash but I still received the following error from AutoCAD's commandline:

; error: Automation Error. Invalid input

 When I comment the vla-put-CanonicalMediaName setting out, or change it to a paper size with only spaces and alphanumeric characters, the functions run flawlessly.

Even when I run the "-PLOT" command and follow the prompts, the program accepts the paper-size I'm trying to set through this LISP command.

 

Is there a different function I'm supposed to call? Or is my installation of AutoCAD 2009 behaving abnormally?

 

Thank you for any input you may have.

 

The entire code I'm running is as follows.

(defun c:pagesetups()
    ;; Get the current drawing
    (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
    ;; Get the PlotConfigurations collection
    (setq plotCfgs (vla-get-PlotConfigurations doc))

    ;; Check to see if the pagesetup already exists
    (setq plotCfg (vl-catch-all-apply 'vla-Item (list plotCfgs "Named Page Setup 1")))

    ;; If the page setup exists, the variable will be of type VLA-OBJECT
    (if (/= (type plotCfg) 'VLA-OBJECT)
        ;; Create a page setup for model
        (setq plotCfg (vla-Add plotCfgs "Named Page Setup 1" :vlax-true))
    )

    ;;(vla-put-Name plotCfg "Named Page Setup 1")
    (vla-RefreshPlotDeviceInfo plotCfg)
 
    ;; Set the plot device
    (vla-put-ConfigName plotCfg "DWG To PDG.pc3")
    ;; Set the paper size
    (vla-put-CanonicalMediaName plotCfg "ANSI B \(11.00 x 17.00 Inches\)");<-- HERE'S WHERE THE ERROR OCCURS (I THINK)
    
    (vla-put-PaperUnits plotCfg acMillimeters)

      (setq PLOT_BL (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 1)) '(-53.540381 -6.990000))
        PLOT_TR (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 1)) '(814.00000000 537.00000000))
    )
    (vla-SetWindowToPlot plotCfg PLOT_BL PLOT_TR)
    (vla-put-PlotType plotCfg acWindow)

    (vla-put-UseStandardScale plotCfg :vlax-true)
    (vla-put-StandardScale plotCfg ac1_2)
    (vla-put-CenterPlot plotCfg :vlax-false)
    ;; Hide paperspace objects
    (vla-put-PlotHidden plotCfg :vlax-false)

      ;; Set the plot offset
    (setq origin (vlax-make-safearray vlax-vbDouble '(0 . 1)))
    (vlax-safearray-fill origin (list 0.0 0.0))
    (vla-put-PlotOrigin plotCfg origin)
 
    (vla-put-PlotRotation plotCfg ac90degrees)
    (vla-put-PlotViewportBorders plotCfg :vlax-false)
    (vla-put-PlotViewportsFirst plotCfg :vlax-false)
    (vla-put-PlotWithLineweights plotCfg :vlax-true)
    (vla-put-ScaleLineweights plotCfg :vlax-false)
    (vla-put-PlotWithPlotStyles plotCfg :vlax-true)
    (vla-put-ShowPlotStyles plotCfg :vlax-true)
    (vla-put-StyleSheet plotCfg "MTO_monochrome_Half_Size.ctb")
    (vla-RefreshPlotDeviceInfo plotCfg)

    (princ)
)

 

 

6 REPLIES 6
Message 2 of 7
hmsilva
in reply to: GoldenEye15

Is this plotter name correct?

"DWG To PDG.pc3"

 

You must provide to the function the correct media name...

(vla-put-CanonicalMediaName plotCfg "ANSI_B_(11.00_x_17.00_Inches)")

 

EDIT: to see the paper sizes available

(setq paper (vlax-safearray->list (vlax-variant-value (vla-GetCanonicalMediaNames plotCfg))))

 

HTH

Henrique

EESignature

Message 3 of 7
dbroad
in reply to: GoldenEye15

I believe an error is happening before where you think.

 

;; Set the plot device
    (vla-put-ConfigName plotCfg "DWG To PDG.pc3")

 The pc3 file name is incorrect by one letter.

 

In addition, you do not need to escape the parentheses with a backslash.

Architect, Registered NC, VA, SC, & GA.
Message 4 of 7
GoldenEye15
in reply to: GoldenEye15

Very sorry about that, that was a typo from a few edits I had to make to the code before posting.

 

I fixed the error and it's still giving me invalid input.

 

After doing some research, I discovered that paper-size have two names: CanonicalMediaName and LocaleMediaName. Would the vla-put-CanonicalMediaName accept the LocaleMediaName of a paper size?

 

Also, how would I get the LocaleMediaName?

Message 5 of 7
hmsilva
in reply to: GoldenEye15

Did you try this?

(vla-put-CanonicalMediaName plotCfg "ANSI_B_(11.00_x_17.00_Inches)")

 

Henrique

EESignature

Message 6 of 7
GoldenEye15
in reply to: hmsilva

That worked exactly. I never would have thought about using underscores in place of spaces.

 

Thank you very much, sir! Your solution is much simpler than what mine was going to be.

Message 7 of 7
hmsilva
in reply to: GoldenEye15

You're welcome.
I have suggested this approach in Message #2...

Henrique

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost