Jump to content

Search the Community

Showing results for tags 'vba'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • CADTutor
    • News, Announcements & FAQ
    • Feedback
  • AutoCAD
    • AutoCAD Beginners' Area
    • AutoCAD 2D Drafting, Object Properties & Interface
    • AutoCAD Drawing Management & Output
    • AutoCAD 3D Modelling & Rendering
    • AutoCAD Vertical Products
    • AutoCAD LT
    • CAD Management
    • AutoCAD Bugs, Error Messages & Quirks
    • AutoCAD General
    • AutoCAD Blogs
  • AutoCAD Customization
    • The CUI, Hatches, Linetypes, Scripts & Macros
    • AutoLISP, Visual LISP & DCL
    • .NET, ObjectARX & VBA
    • Application Beta Testing
    • Application Archive
  • Other Autodesk Products
    • Autodesk 3ds Max
    • Autodesk Revit
    • Autodesk Inventor
    • Autodesk Software General
  • Other CAD Products
    • BricsCAD
    • SketchUp
    • Rhino
    • SolidWorks
    • MicroStation
    • Design Software
    • Catch All
  • Resources
    • Tutorials & Tips'n'Tricks
    • AutoCAD Museum
    • Blocks, Images, Models & Materials
    • Useful Links
  • Community
    • Introduce Yourself
    • Showcase
    • Work In Progress
    • Jobs & Training
    • Chat
    • Competitions


  • Programs and Scripts
  • 2D AutoCAD Blocks
  • 3D AutoCAD Blocks
  • Images
    • Backgrounds

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...

Found 64 results

  1. Good day everyone, I like to merge three blocks attributes to one block with attributes. I'm not good at VBA. I hope someone correct the below code for me. Thanks Public Sub Merge_LnBLk() Dim ss As ZcadSelectionSet Dim UNode As ZcadText Dim UGL As ZcadText Dim UIL As ZcadText Dim DNode As ZcadText Dim DGL As ZcadText Dim DIL As ZcadText Dim LnLen As ZcadText Dim Size As ZcadText Dim GetPt As Variant Dim BlkName As String Dim NodeBlk As ZcadBlockReference Dim FromBlk As ZcadBlockReference Dim ToBlk As ZcadBlockReference Dim SizeBlk As ZcadBlockReference Dim objAttribs As Variant Dim FromobjAttribs As Variant Dim ToobjAttribs As Variant Dim SizeobjAttribs As Variant On Error Resume Next ThisDrawing.SelectionSets("s").Delete On Error GoTo 0 Set ss = ThisDrawing.SelectionSets.Add("s") ss.SelectOnScreen Set FromBlk = ss.Item(0) Set ToBlk = ss.Item(1) Set SizeBlk = ss.Item(2) GetPt = ActiveDocument.Utility.GetPoint(, "Pick where the block to be inserted") BlkName = "LNNode" Set NodeBlk = ActiveDocument.ModelSpace.InsertBlock(GetPt, BlkName, 1, 1, 1, 0) FromobjAttribs = FromBlk.GetAttributes() UNode.TextString = FromobjAttribs(0) UGL.TextString = FromobjAttribs(1) UIL.TextString = FromobjAttribs(2) ToobjAttribs = ToBlk.GetAttributes() DNode.TextString = ToobjAttribs(0) DGL.TextString = ToobjAttribs(1) DIL.TextString = ToobjAttribs(2) SizeobjAttribs = SizeBlk.GetAttributes() LnLen.TextString = SizeobjAttribs(0) Size.TextString = SizeobjAttribs(1) objAttribs = NodeBlk.GetAttributes() objAttribs(0).TextString = UNode objAttribs(1).TextString = UGL objAttribs(2).TextString = UIL objAttribs(3).TextString = DNode objAttribs(4).TextString = DGL objAttribs(5).TextString = DIL objAttribs(6).TextString = LnLen objAttribs(7).TextString = Size NodeBlk.Update End Sub TestBlocks.dwg
  2. I found valuable lisp for auto creation block. I want to improve this lisp to following requirement * block selected object individually, not in one block thanks AUTO-BLOCK.LSP
  3. I am using AutoCAD VBA with array. I need to call a LISP function to pass a parameter (array). How can I the pass an array from VBA to LISP? I am using this expression: ThisDrawing.SendCommand "Myfunction"
  4. NBCAD


    Hello, As part of a project I must assign an object data table to all elements of the drawing according to their layer. I am looking for an automated solution to assign the Objects Data tables to the elements of the drawing other than by selecting the different layers one by one. Knowing nothing in programming, I ask you to find ways to achieve this result. On the other hand, once the object data tables (Object data) assigned to the various elements I want to find a way fast enough to copy some attribute objects in the corresponding "Object Data" fields. For example copy the value of the orientation of a block (Attribute Value "Rotation") in the corresponding OD field (Attribute Value "ARE_ORIENT"), as in the attachment. I am currently doing these manipulations by hand and this is a huge waste of time. I am interested in any solution as small as it is! Thank you!!
  5. katto01

    VBA delete object

    Hello, I have a drawing with about 15000 objects. I would like to delete all objects with a volume smaller than Vx. I cannot see all objects, I can access them through VBA. I generated a list of objects and extracted the handle and the maximal dimensions. Therefore, I know by handle which object I want to delete. What is the VBA command to delete an object defined by its handle? If this approach cannot be implemented, please suggest alternatives Thank you
  6. Cleyton Ramos

    Get info from insertblock

    Hello! How do I get the information from an insertblock by clicking it? Thank you very much in advance.
  7. Cleyton Ramos


    Hello! I'm having trouble getting the intersection points on a straight line. Can you post a simple example? thankfull
  8. Anyone has a code to accomplish this? I am dealing with bunch of poorly converted lines from PDF that used to be AutoCAD text in the drawing. Greatly appreciated!
  9. Hello Anybody Help. I need to get point from spline with use lisp function in autocad vba vlax-curve-getPointAtDist Could somebody can help me? Best Regard Joe
  10. Hi to all, please somebody know how to manage the ampoweredit functionality and related dialog windows by VBA personalizzation ?
  11. Hi, I'm new to AutoCAD. I have 700 drawings in AutoCAD. I have to enter "Checker" value in the drawing title block. For all the drawings, its the same value. How to I automate this? I don't want to open manually individual drawing and fill the value. Any macro available for this? Please help. Regards, Prasanna.A
  12. Hello, I am trying to create a dimension style using VBA Excel. I have a simple code as follows: Option Explicit Sub New_Layer() Dim acadApp As AcadApplication Dim acadDoc As AcadDocument Dim mSp As AcadModelSpace Dim dimstyle As AcadDimStyle Dim sDim As AcadDimAligned Dim point1(0 To 2) As Double Dim point2(0 To 2) As Double Dim location(0 To 2) As Double 'Check if AutoCAD is open. On Error Resume Next Set acadApp = GetObject(, "AutoCAD.Application") On Error GoTo 0 'If AutoCAD is not opened create a new instance and make it visible. If acadApp Is Nothing Then Set acadApp = New AcadApplication acadApp.Visible = True End If 'Check if there is an active drawing. On Error Resume Next Set acadDoc = acadApp.ActiveDocument On Error GoTo 0 'No active drawing found. Create a new one. If acadDoc Is Nothing Then Set acadDoc = acadApp.Documents.Add acadApp.Visible = True End If Set mSp = acadDoc.ModelSpace 'Dimension points point1(0) = 0#: point1(1) = 5#: point1(2) = 0# point2(0) = 6.1: point2(1) = 5: point2(2) = 0# location(0) = 5#: location(1) = 4.4: location(2) = 0# 'Add dimension Set sDim = acadDoc.ModelSpace.AddDimAligned(point1, point2, location) 'Set dimension properties sDim.Color = acByLayer sDim.ExtensionLineExtend = 0 sDim.Arrowhead1Type = acArrowOblique sDim.Arrowhead2Type = acArrowOblique sDim.ArrowheadSize = 0.1 sDim.TextColor = acGreen sDim.TextHeight = 0.2 sDim.UnitsFormat = acDimLDecimal sDim.PrimaryUnitsPrecision = acDimPrecisionOne sDim.TextGap = 0.1 sDim.LinearScaleFactor = 100 sDim.ExtensionLineOffset = 0.1 sDim.VerticalTextPosition = acOutside 'Create a new dimension style Set dimstyle = acadDoc.DimStyles.Add("D100") 'Copy dimension properties from previously added dimension dimstyle.CopyFrom (sDim) 'Delete dimension sDim.Delete End Sub However dimstyle.CopyFrom (sDim) line does not working. I am getting following error: "Object doesn't support this propert or method" I couldn't find what I am doing wrong. I am using AutoCAD 2013 and Excel 2016. Thank you!
  13. selvamani

    Printing Customization

    Hi All, I need help in customizing printing cad files actually in my case single drawing would have multiple sheets in single model space so it will have multiple title block is there any way to print entire region inside title block one by one by means of vba scripting? (i mean is there any way to sense outer boundary of title block in vb and set it as printing area) Having thousands of cad files in which work area in model space of any two drawing is not same thanks in advance Drawing2.dwg
  14. My VBA application requires info from one drawing to be used in another one in the same VBA running session. I need to ALIGN one drawing based upon 3 3D points from another draiwng automatically. At the moment I'm running my application to collate the info from drawing 1, store it, close my application to open the other drawing and run my application again to retrieve the info to ALIGN it. Any idea how I can switch to another loaded drawing in the same VBA running session? Thanks!
  15. Is it possible to exclude from a vba macro for Autocad a specific region? For example, apply this macro not to all modelspace but only to a part (which has not lines as boundaries but defined only by position reference x,y in autocad). Thanks
  16. ElCidCampeador

    VBA Autocad: How to find lines?

    I'm trying to write a VBA code that searches in a general drawing all lines that have a specific length and slope. Then, every time it finds that line in the drawing, it will write next to a specific text, for example "line". Do you think it's possibile? Any idea? Thanks
  17. ElCidCampeador

    Recognize multi-object shape

    Hi, I converted a pdf file into dwg. In this new file a point has become a group of 2D polyline and not a sigle entity. This conversion is necessary because I have to work in autocad. My problem is that I have to search in this dwg all of this "points" and write a text next to. Is possible to write a VBA program for autocad able to do this? If the point was a single point, it wouldn't be a problem, but in this case...I dont' know!
  18. Hi First time poster here. I've only got AutoCAD13 and there's almost no chance for us to get civil 3d. But I have a 4km pipeline i'm trying to model so I'll need a longsection. Besides doing it manually is there a more efficient method, given the contour file I have is at 0.5m intervals. I'm thinking even a script in Excel that pulls the intersect for the pipeline polyline and contour lines and return the x-y-z coordinates. Thanks
  19. Hi everybody, I have a big problem.... I have about 100 DWG with a lot of sheet in the same model space and i must print every sheet, so i am looking for a script in VBA or lisp to create from multiple areas to plot in model space, a layout tab for each area vba autocad. I found a lisp script, but it doesn't run (plotDWGarr). (http://www.cadforum.cz/cadforum_en/plotting-a-series-of-drawing-frames-composed-in-a-dwg-drawing-tip7585) Do you know another similar script o to write a VBA to do it? Thank you very much in advance
  20. Hi Everybody, Via the command area it is possible to retrieve the surface area of a solid body (Acad3DSolid). Unfortunately the area it is not a property of a solid body so I'm haveing difficulties retrieving the surface area (which I want to write to an excel file). I've tried to explode the solid which results in several regions and surfaces. Unfortunately only the regions have an area; the (curved) surfaces don't. Anybody suggestions how to get the area of some solids useing VBA? Looking forward to the suggestions!
  21. I met a very "strange" behavior of VBA with Fillet Command send via ThisDrawing.SendCommand function. I have the function Fillet_2Line (line1, line2, r), which will apply the Fillet command to line1, line2 with Radius=R Sub fillet_2line(line1 As Variant, line2 As Variant, radius As Double) Dim text As String text = "f" & vbCr & "r" & vbCr & radius & vbCr & "(handent " & Chr(34) & line1.Handle & Chr(34) & ")" & vbCr & "(handent " & Chr(34) & line2.Handle & Chr(34) & ")" & vbCr ThisDrawing.SendCommand (text) End Sub As you can see, the function is very simple, call Fillet command from Autocad then select two lines by their handle. Use can reproduce the function without VBA by call Fillet command and select two POLILINES by their HANDLE. However, it works on LINE, but NOT POLYLINE. If I select two polylines by left click on them, it works. But if I select two polylines by their HANDLE, it does not work! Fillet 2 Line - Selected by left click - Works Fillet 2 Line - Selected by handle - Works Fillet 2 PLine - Selected left click - Works Fillet 2 PLine - Selected by handle - Does not work
  22. Hello, I'm a new user about autocad and new user about this Forum. I try use VB and CAD... Is there a solution for my problem in object? i just write code for MSGBOX: Dim Variabile As Integer Variabile = MsgBox("Hai esportato i parametri?", vbOKCancel) If Variabile = 2 Then ActiveWindow.Close and work if use a macro....but for insert this message when close a file? can i make a particular macro for this like excel or access??? thanks for You interest
  23. Hi There Sorry that this will be such a basic question. I am not a VBA expert in any way....quite new actually . Running Autocad Architecure 2014. I have a VBA utility that I have made a special button for. I want this button to insert a dynamic block. I have WBLOCK'ed the block and it is in a nework folder - no issues here. There are several other snippets of VBA code that I have found online (even from this forum) and have tried to modify them to work. I must be doing something wrong, as it always stumbles within the code or silently sits there doing nothing. I just want to click this button and my dynamic block (from network) will be brought into the existing drawing, and the user will select insert point and direction..... Mouse click...done....block inserted. Similar action to a block that would be brought from a tool pallette (but has to be from this VBA utility) Any help would be appreciated. Matt
  24. Hi Everyone I know this and similar questions have already been posted in many forums, and before you start copy pasting links of other threads, you have to know that I probably have seen them already and none of them is 100% perfect answer to what I am trying to achieve. And now I will describe my situation and my issue. I am a REVIT guy but I recently started a new job in an office that uses primarily Autocad. I am currently in the process of creating office standards. The problem is that it does not happen over night. At the moment I am mainly relying on (dynamic) blocks. As I keep creating them, I save them in a template file - let's call it "XYZ". We currently have 40-50 active projects. Some new, some old. When I myself am working on a project - what I do is "copy/paste" all the blocks from the XYZ file so i can use them in the currently open project. The problem is that my colleagues are either stupid enough not to know or remember (how) to "copy/paste" the blocks or are just so lazy that can not be bothered (completely unpleasant environment). So what I want to achieve is: whenever someone opens an Autocad drawing, to have all the blocks from the "XYZ" file already loaded. Or alternatively have all the WBLOCK files loaded from a specific directory like c:\Autocad\abcd... Bear in mind that this is not 1 time thing that needs to be performed on all the active project drawings. I keep creating new blocks every day. Please do not respond with "This can be achieved by....". I am looking for a way not to have anyone do anything, but Autocad do all the work. I would much rather be satisfied with "This cannot be achieved" answer, rather than having people enter JUST a few commands to get it done. My colleagues are stupid and they won't press an extra key to get the blocks loaded. I would be really grateful if anyone can help me. If not, nothing changes, I have already lost faith...
  25. Hi, I need to extract Information ("General": Color, etc. and "Geometry": Length, Start Y, End X, etc.") from AutoCAD to an Excel-Sheet using VBA. First I've tried it manually in AutoCAD with the commands DATAEXTRACTION and EATTTEXT and it works. Also I've tried entering in VBA "SendCommand ("DATAEXTRACTION" & vbCr")", then an AutoCAD-window is opened and I have to click on "Next" several times and to specify the folder where I want to save the file. I want that VBA does all this process without the window appearing (I mean "without clicking on "Next" several times and specifying the file path"). Obvious the User has to Input into the code the location where he wants to save the file with the extracted information). Instructions als "For Each Object in ModelSpace: Line.StartPoint, Line.Color, etc." don't help me unfortunately because this way slow down the VBA-program. May anyone help me? Thanks! Regards,
  • Create New...