Forum discussion between experts.
Covers toggling Profiles and connecting the VBA to a button option.
(Concepts could be applied generally.)
From: Jon Baker
R&R Engineers-Surveyors, Inc.
Denver, Colorado
Date: Aug/21/01 - 00:33 (GMT)
Is there a way to toggle between profiles with in AutoCAD?
From: Walter ---http://www.ActiveDwg.com
Date: Aug/21/01 - 00:16 (GMT)
See if this works for you. Replace 'Profile1.arg'/'Profile2' as required.
Sub ad_SwapProfiles()
Dim adPrefs As AcadPreferences
Dim adLoadFile As String
Dim adProfileName As String
Set adPrefs = ThisDrawing.Application.preferences
If adPrefs.Profiles.ActiveProfile = "Profile1" Then
adLoadFile = "Profile2.arg"
adProfileName = "Profile2"
Else
adLoadFile = "Profile1.arg"
adProfileName = "Profile1"
End If
On Error GoTo NoFile
preferences.Profiles.ImportProfile adProfileName, adLoadFile, True
Exit Sub
NoFile:
MsgBox "Profile Import Failed:" & Err.Description
End Sub
To set it up:
1)In AutoCAD hit 'ALT-F11' to enter the VBA editor,
2)Select 'Insert>Module',
3)Copy and paste the code into the module,
4)Switch back to AutoCAD,
5)Hit 'ALT-F8',
6)Highlight the line with 'ad_SwapProfiles',
7)Click 'Run'.
OR
1)Follow 1-3 above,
2)Save the module as a file,
3)Place it in the 'Autocad\Support' folder as 'ad_SwapProfiles.dvb',
4)Set up a custom toolbar button with this as its macro:
^C^C-vbarun;ad_SwapProfiles.dvb!ad_SwapProfiles;
5)You can now load and run it by clicking the button...
- - o 0 o - -
               (
geocities.com/wpsmoke)