autocad

Move Coordinates of Polyline After It Is Already Drawn

Sub MoveCoordinatesPolylineAfterAlreadyDrawn() Dim VFG(7) As Double Dim retCoord(0 To 1) As Double Set acadApp = GetObject(, "AutoCAD.Application") Set acadDoc = acadApp.ActiveDocument Set objss = acadDoc.SelectionSets.Add("ToErase") objss.Select acSelectionSetAll objss.Erase objss.Delete VFG(0) = 0: VFG(1) = 0 'vertex 1 VFG(2) = 0: VFG(3) = -5 'vertex 2 VFG(4) = 10: VFG(5) = -5 'vertex 3 VFG(6) =… Continue reading Move Coordinates of Polyline After It Is Already Drawn

3D AutoCAD

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

autocad

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

autocad

Find Intersect Between Two Block Objects

This code will create two blocks that have a light weight polyline of a triangle and a trapezoid. We want the two object to have a specific gap between them without intersecting. WE CAN DO THIS! No Calculus required. We do this by exploding the block and then offsetting the polyline a specific distance with… Continue reading Find Intersect Between Two Block Objects

autocad

Change Tags of all MultiLeader objects

This example shown is for a custom multileader that has additional attributes; although with slight modification it can also work with standard multileader. This is useful when trying to match the pcmarks with the Bill of Material items in a table. The code can be expanded to loop through a BOM table, for simplicity I… Continue reading Change Tags of all MultiLeader objects

3D AutoCAD

AddSpline Method

This example will grab scanned data from an excel file and create a visual representation of the scan data in AutoCAD by drawing splines. I haved uploaded the excel file for viewing reference Scan Data_to_Autocad.xlsm Results: Drawn Splines Excel Scanned Data Option Explicit Public MTextObj As AcadMText Public ACLayout As AcadLayout Public acadApp As Object… Continue reading AddSpline Method

autocad

Grab Attribute Data from Dwg Files in a Folder

This example will let user select a folder that contains dwg files. It then opens each drawing and extracts attribute data from all the blocks. The data is then put in an excel table. The table is then sorted according to the y coordinate insertion point of each block. For this example I have a… Continue reading Grab Attribute Data from Dwg Files in a Folder

autocad

Delete All Drawing Objects

This is useful when you are creating drawings from a template that has inserted blocks or pre-drawn objects. It is also helps when creating many CNC drawings. Instead of creating a new drawing each time, just create one drawing, create objects, save as, delete all, create objects, save as, and repeat until all the CNC… Continue reading Delete All Drawing Objects

autocad

Editing Dynamic Block Attributes

Paste the following code into excel VBA module. Next add a folder named 'support' and put the dwg file that has all your dynamic blocks. Keep the 'support' folder in the same folder as the excel workbook. See this post on creating dynamic blocks https://pearlsnake.com/2019/05/20/creating-dynamic-blocks-in-autocad/ . I have also uploaded a folder called 'support' on… Continue reading Editing Dynamic Block Attributes