Instead of drawing on the default top view. The code below will show how to draw on the front view ' set the world ucs With acadDoc Set currUCS = .UserCoordinateSystems.Add(.GetVariable("UCSORG"), .Utility.TranslateCoordinates(.GetVariable("UCSXDIR"), acUCS, acWorld, 0), .Utility.TranslateCoordinates(.GetVariable("UCSYDIR"), acUCS, acWorld, 0), "OriginalUCS") End With 'Create a UCS and make it current origin(0) = 0: origin(1) = 0: … Continue reading Draw on UCS Front View
Add a Viewport and Show Front View
This will create a viewport in paper space and instead of the standard top view, the viewport will show as the front view center(0) = 5.4682: center(1) = 1.4055 dblviewdirection(0) = 0: dblviewdirection(1) = -1: dblviewdirection(0) = 0 Set pviewportObj = acadDoc.PaperSpace.AddPViewport(center, vpwidth, 2.2565) pviewportObj.direction = dblviewdirection pviewportObj.Layer = "viewport" pviewportObj.Display True acadDoc.MSpace = True … Continue reading Add a Viewport and Show Front View
Veiwports with TranslateCoordinates and CHSPACE
The code below will draw a viewport in paper space and zoom to an area in model space. It will then create a circle in model space and then change that circle to to papers pace while still keeping the circle in the same location. Note: for this to work, the MSpace has to be … Continue reading Veiwports with TranslateCoordinates and CHSPACE
ByRef vs ByVal
When passing arguments to a procedure (sub or function) the default will be 'byRef' in Excel VBA, thus you don't have to write 'byRef' before the variable. If you want to pass ByVal you have to explicitly write 'ByVal' before the variable. When using ByVal you are only passing a copy of the argument to … Continue reading ByRef vs ByVal
Run a Macro at a Specific Time
Sub ImportModules() Debug.Print "test" End Sub Private Sub Workbook_Open() Application.OnTime Now + TimeValue("00:00:01"), "domeprog.ThisWorkbook.ImportModules" End Sub The code above will run the macro called 'ImportModules' one second after the workbook is opened. If the macro is located in a class module or in ThisWorkbook class, then you will need to call out the library + … Continue reading Run a Macro at a Specific Time
Add items to a UserForm ComboBox
When you don' t want the user to input their own value, set the combobox style to 2. This will force the user to pick from the list of items. The default style is 0, it will behaves as a drop-down combo box or a region to type any value. ComboBox54NozzleSize.sytle = 2 '0=fmStyleDropDownCombo '2=fmStyleDropDownList … Continue reading Add items to a UserForm ComboBox
Public Variables in VBA
USE CAUTION! Any time you declare a variable as public it is important to understand all the consequences and how they behave. In order to make a variable public it has to have the keyword 'Public' rather than 'dim'. It also has to be declared in a module before the first procedure declaration. It does … Continue reading Public Variables in VBA
Check If Each Input Box is filled
Many times you don't want a user to proceed until all input boxes are filled. To solve this you can loop through each control with a For Each statement. For Each will be especially useful when you there are many controls and you don't want to reference each name individually. The examples below show how … Continue reading Check If Each Input Box is filled
Viewports and Dimension Scales
Often times its nice to create a drawing package where all the geometry and dimension and text are drawn in model space and want to make different layout tabs showing all the different geometries in the model space. We want all the text and dimensions to be the same size throughout all the print pages. … Continue reading Viewports and Dimension Scales
Clear All Check Boxes In Excel VBA Userform
This example uses a for each loop so that each check box name does not have to be explicitly written out. This is useful when you are adding more control and limit the amount of code you are writing. Better Method Dim ctrl As Control Sub ClearAllButton_Click() For Each ctrl In exportFilesUF.Controls If TypeName(ctrl) = … Continue reading Clear All Check Boxes In Excel VBA Userform