Run ConvertPStyles Silent

Run ConvertPStyles Silent

rich.mikulec
Contributor Contributor
996 Views
14 Replies
Message 1 of 15

Run ConvertPStyles Silent

rich.mikulec
Contributor
Contributor

I have created the below script to automatically convert a drawing from stb to ctb.

However the command CONVERTPSTYLES always pops up a dialog box requiring a stoppage in the code just to press OK.

 

richmikulec_0-1731430502487.png

 

 

If there any way to make this command run silent? Not pop up a Dialog box?

Or is there an alternate way to convert a drawing that is using stb to ctb silently"

 

 

I have tried:

  cmdeco 0

  cmddia 0

 

  variations of

     (command "_.ConvertPStyles" _"Yes")

     (command "_.ConvertPStyles" _"OK")

     (command "ConvertPStyles")

 

 

 

defun STBtoCTB ()
(princ "\nSTBTOCTB----CHECKS PLOT SETTING FOR CTB...DONE\n")

;; Initialize a flag to check if any CTB assignment was made
(setq assignment-made nil)

;; Main function body
(if (= (getvar "PSTYLEMODE") 0) ; Check if the drawing is in STB mode
(progn
(setq oldcmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)

;; Run CONVERTPSTYLES to switch to CTB
(command "ConvertPStyles")
;; Assign the specified CTB file to Model Space

(command "._-plot" "y" "model" "Plotter" "Tabloid" "inches" "l" "n" "e" "f" "CENTER" "y" "NewCTB.ctb" "y" "a" "n" "y" "n")


;; Set flag to indicate assignment was made
(setq assignment-made t)

;; Assign the specified CTB file to each Layout in Paper Space
(foreach layout (layoutlist)
(if (/= layout "Model") ; Skip the Model layout if listed
(progn
(setq oldcmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "._-plot" "y" layout "Plotter" "Tabloid" "inches" "l" "n" "e" "f" "CENTER" "y" "NEWctb.ctb" "y" "n" "y" "n" "n" "Y" "n")
(setvar "CMDECHO" oldcmdecho)

;; Set flag to indicate assignment was made
(setq assignment-made t)
)
)
)

;; Only display the message once if any assignment was made
(if assignment-made
(princ "\nThe drawing has been converted from STB to CTB and assigned the specified CTB file to both Model and Paper Space.\n")
)
)

;; Message for when no conversion is needed
(princ "The drawing is already using CTB plot styles. No conversion needed.\n")
)
)

 

 

 

AutoCAD since Rel 7
AutoCAD 2024 (Mechanical, Electrical, Inventor)
VaultPRO 2024 (Vault Admin)
Inventor 2024 (Design, Factory, Simulate)
0 Likes
Accepted solutions (1)
997 Views
14 Replies
Replies (14)
Message 2 of 15

pendean
Community Legend
Community Legend

@rich.mikulec is this what you want

 

(cond
((= 0 (getvar "PStyleMode")) (command "._ConvertPStyles"))
)

 

pendean_0-1731431496758.png

 

0 Likes
Message 3 of 15

rich.mikulec
Contributor
Contributor

The code works correctly. The issue is with the function of the command:

 

(command "._ConvertPStyles")

 

When this line is run, it posts a msg box that requires an OK response.

 

I am looking for it to be silent. No intervention.

 

AutoCAD Mechanical 2024

AutoCAD since Rel 7
AutoCAD 2024 (Mechanical, Electrical, Inventor)
VaultPRO 2024 (Vault Admin)
Inventor 2024 (Design, Factory, Simulate)
0 Likes
Message 4 of 15

Kent1Cooper
Consultant
Consultant

Shot in the dark [I haven't looked] -- does the EXPERT System Variable have a value that suppresses that?

Kent Cooper, AIA
0 Likes
Message 5 of 15

rich.mikulec
Contributor
Contributor

Yes. I tried 0-5.

 

richmikulec_0-1731438055103.png

 

AutoCAD since Rel 7
AutoCAD 2024 (Mechanical, Electrical, Inventor)
VaultPRO 2024 (Vault Admin)
Inventor 2024 (Design, Factory, Simulate)
0 Likes
Message 6 of 15

pendean
Community Legend
Community Legend

@rich.mikulec wrote:

...AutoCAD Mechanical 2024


I'm not running MECH, just plain AutoCAD, and the entire code as I wrote exactly converts a named style DWG to a color-dependent with no pop-ups or anything other than a confirmation the DWG got converted.

pendean_0-1731439380820.png

 

Tested in plain AutoCAD 2023-24-25, and since you got me intrigued, also in MECH/ARCH/MEP/ELEC/P3D (2023 versions) that just happen to be on my PC, aka still no pop-up and no need to OK out of anything

pendean_1-1731439658321.png

pendean_3-1731439801416.png

 

 

pendean_2-1731439742831.png

pendean_4-1731439839819.png

 

BUT... MECH2023 above is without add-ons and pretty much an OOTB installation that is fully updated. I don't have any of your STB-centric DWG files to try it on. But you do, or if you can share... ?

0 Likes
Message 7 of 15

rich.mikulec
Contributor
Contributor

I just went and copied the code into base vanilla AutoCAD. And it posted the msgbox.

 

richmikulec_0-1731441314251.png

 

richmikulec_1-1731441339766.png

 

Curious. what happens when you type the command convertpstyles manually? Does it post the msgbox?

 

File attached

 

 

AutoCAD since Rel 7
AutoCAD 2024 (Mechanical, Electrical, Inventor)
VaultPRO 2024 (Vault Admin)
Inventor 2024 (Design, Factory, Simulate)
0 Likes
Message 8 of 15

rich.mikulec
Contributor
Contributor

FYI, I added the LSP routine to the CUI Lisp section so that it runs whenever a file is opened.

 

richmikulec_0-1731441890445.png

 

I did also try with Appload and it acts the same way.

AutoCAD since Rel 7
AutoCAD 2024 (Mechanical, Electrical, Inventor)
VaultPRO 2024 (Vault Admin)
Inventor 2024 (Design, Factory, Simulate)
0 Likes
Message 9 of 15

pendean
Community Legend
Community Legend

@rich.mikulec No pop-ups here, your file is converted silently with a notification at the commandline.

pendean_0-1731444496555.png

 

pendean_1-1731444715251.png

 

 


@rich.mikulec wrote:

....what happens when you type the command convertpstyles manually? Does it post the msgbox?...


Of course it brings up the dialog box, nothing surprising there.

pendean_2-1731444802375.png

 

0 Likes
Message 10 of 15

Rick_Tolleshaug_TSC
Advocate
Advocate

If I'm understanding status of this thread, that unlike plain AutoCAD, message still pops-up in AutoCAD Mechanical when called via command function, here is something else to try...

In plain AutoCAD, command ConvertPStyles loads accvps.arx. Assuming AutoCAD Mechanical has its own accvps.arx, wondering if swapping files would do anything? Attached is zipped-up accvps.arx from AutoCAD 2025.1.1, which resides in directory "C:\Program Files\Autodesk\AutoCAD 2025".

0 Likes
Message 11 of 15

rich.mikulec
Contributor
Contributor

The issue exists in plain AutoCAD as well for me. I am working in 2024. Did something change in 2024 or any recent updates?

Are there any system variables that could be affecting how convertpstyles operates?

 

I have tested in 2025 and no popo up. I am investigating if there is a  sysvar difference in 2024.

 

We are still on Vault 2024, so cannot move yet.

AutoCAD since Rel 7
AutoCAD 2024 (Mechanical, Electrical, Inventor)
VaultPRO 2024 (Vault Admin)
Inventor 2024 (Design, Factory, Simulate)
0 Likes
Message 12 of 15

pendean
Community Legend
Community Legend

@rich.mikulec wrote:

...I have tested in 2025 and no popo up. I am investigating if there is a  sysvar difference oin 2024.


Any reason you don't want to adopt and use AutoCAD2025? Just ensure it is at the 2025.1.1 update level.

0 Likes
Message 13 of 15

paullimapa
Mentor
Mentor

I'm running 2024.1.6 and I don't get that popup.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 14 of 15

Rick_Tolleshaug_TSC
Advocate
Advocate
No pop-up for me using (command "convertpstyles") in AutoCAD 2022.1.5, 2024.1.6 or 2025.1.1.
0 Likes
Message 15 of 15

rich.mikulec
Contributor
Contributor
Accepted solution

I wanted to provide follow-up.

 

I ended up having to RESET my AutoCAD software. Not sure what got changed, but once that was completed, the commands starting working as expected.

 

richmikulec_0-1734031740490.png

 

KIM, RESET does just that, brings the software back to its starting point at install. All customizations removed.

 

Thank you for the help.

AutoCAD since Rel 7
AutoCAD 2024 (Mechanical, Electrical, Inventor)
VaultPRO 2024 (Vault Admin)
Inventor 2024 (Design, Factory, Simulate)
0 Likes