Search the Community
Showing results for tags 'vba'.
-
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!
-
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
- 2 replies
-
- long section
- excel
-
(and 3 more)
Tagged with:
-
VBA CODE-From multiple areas to plot in model space to create a layout for each areas
FrancescoITA posted a topic in .NET, ObjectARX & VBA
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- 9 replies
-
- model space
-
(and 1 more)
Tagged with:
-
VBA Code to retrieve the surface area of a solid body for writing to excel
RemiS posted a topic in .NET, ObjectARX & VBA
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!-
- solid body
- excel
-
(and 3 more)
Tagged with:
-
VBA - Command Fillet on 2 single Polyline does not work!
khoinp1012 posted a topic in .NET, ObjectARX & VBA
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 -
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
-
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
-
Autocad blocks having loaded automatically from specific directory or file!!!
yudjee posted a topic in AutoCAD General
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... -
VBA Data Extraction to Excel-Sheet (DATAEXTRACTION; EATTEXT)
vjdazam posted a topic in .NET, ObjectARX & VBA
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, -
hello evryone , i'm looking to make a VBA code to get a setected coordinate point (x,y and Z) directly to excel sheet . thank you for your help
-
Hi! I would like a macro which will add a text attribute from an x-ref file to another block attribute which is up to 1.5m around the x-ref element. example: Attribute block: WF-PC-L2.0-095 X-REF attribute: L2.0-0368 I' d like to add L2.0-0368 to WF-PC-L2.0-095. The distance between the 2 attributes is no more than 1.5m perimetrically. I guess coordinates can be the common reference, but i am not faamiliar with coding..
-
- macro
- attribute reference
-
(and 1 more)
Tagged with:
-
Hi, iv got the below vba in progress, i copied it from somewhere online but cannot remember where to give credit Anyway iv got it running from a userform but it will only update the last block inserted. Eventually i want to use it to control 5+ dynamic block, also with visibility states but im at a loss after trying multiple things over the last few hours. Can someone point me in the right direction please? Public Sub block_dyn() Dim objBlock As AcadBlockReference 8 Dim FilterType(0) As Integer Dim FilterData(0) As Variant Dim p1(0 To 2) As Double Dim p2(0 To 2) As Double Dim ssetObj As AcadSelectionSet On Error Resume Next ThisDrawing.SelectionSets.Item("SS1").Delete Set ssetObj = ThisDrawing.SelectionSets.Add("SS1") FilterType(0) = 0 FilterData(0) = "" ssetObj.Select acSelectionSetAll, p1, p2, FilterType, FilterData For Each Item In ssetObj If objBlock.EffectiveName = "Box" Then Set objBlock = ssetObj.Item(n) Call dyn_prop(objBlock, "Width", TextBox3.Value) Call dyn_prop(objBlock, "Height", TextBox4.Value) End If If objBlock.EffectiveName = "Rect" Then Call dyn_prop(objBlock, "Thickness", TextBox3.Value) Call dyn_prop(objBlock, "Depth", TextBox4.Value) End If Next End Sub Public Sub dyn_prop(objBlock As AcadBlockReference, name_of_property As String, value_of_property As Double) Dim dyn_properties() As AcadDynamicBlockReferenceProperty Dim var_atts As Variant var_atts = objBlock.GetDynamicBlockProperties For i = LBound(var_atts) To UBound(var_atts) If var_atts(i).PropertyName = name_of_property Then var_atts(i).Value = value_of_property ThisDrawing.SendCommand "_regen" & vbCr End If Next End Sub Thanks in advance ~D
-
Hi everyone, Ive made a tool to cleanup your dwg-drawings: CLEAN UP XREF V1.1 I want to share it, to help each other! Send me your comment! You can download it below. It contains the follow functions: '************************************************************************ '--- SET_UP_DRAWING --- '1 UCS_WORLD '1 PLANVIEW_UCSWORLD '2 SET_UP_VARIABLES '2 SET_UP_UNITS '3 SCALE_DRAWING '4 LTSCALE_ALL_EXCLUDE_BLOCKS (30) 'WAARDE VAN LTSCALE MEEGEVEN '5 LTSCALE_ALL_BLOCKS (15) 'WAARDE VAN LTSCALE MEEGEVEN '6 FLATTEN_DRAWING '--- SET_UP_LAYERS --- '7 STORE_LAYERSTATE '8 RESTORE_LAYERSTATE '9 SET_LAYER_XREF_TEMP_CURRENT '10 ALL_LAYERS_ON '11 UNLOCK_ALL_LAYERS '12 UNFREEZE_ALL_LAYERS '13 LAYERS_LINEWEIGHT_DEFAULT '14 REMOVE_LAYER_FILTERS '--- CLEANING_STUFF --- '15 PURGE_DRAWING '16 AUDIT_MODELSPACE '17 DELETE_LAYOUTS '18 DELETE_VIEWPORTS '19 DELETE_VIEWS '20 DELETE_DIMENSIONS '21 CLEAN_SCALELIST '--- LAYER_STUFF --- '22 CLEAR_LAYER0 ' DELETE_LAYER ("E-61-ELEKTRISCHE BORDEN") 'HIER DIEN JE NAAM VAN LAYER IN TE VULLEN '23 DELETE_FROZEN_LAYERS '24 ALL_BY_LAYER1 '25 ALL_BY_LAYER2 '--- BLOCKS_STUFF --- '26 ALL_BLOCKS_BY_LAYER '27 BURST_EXPLODE_BLOCKS '28 BURST_EXPLODE_DRAWING_DOWN (3) '29 FIX_BLOCK '--- XREF_STUFF --- '30 TRY_TO_RELOAD_ALL_XREFS_UNLOADED '31 TRY_TO_DETACH_ALL_XREFS_UNLOADED '32 BIND_AND_EXPLODE_ALL_XREFS_LOADED '33 DELETE_UNLOADED_IMAGES '--- EXPORT_STUFF --- '34 CREATE_BACKUP_FILE ' SAVE_AS_XREF ' CREATE_WBLOCK '35 COPY_INTO_TEMPLATE '************************************************************************ Help each other to be helped! CLEAN_UP_XREFSv1.1.zip
-
Automation/Macros in drawings, templates, and part making
andar424 posted a topic in Autodesk Inventor
Hey guys, Just curious and looking for suggestions, but like the title says, what kind of automation or macros do you guys like to run in your Inventor? For example, we tend to have to send pdf's of part prints instead of actual Inventor or CAD formats to manufacturers for release or what not. So, in the drawing template there is a rule that runs and creates (if one doesn't exist) or resaves (if it does exist) a pdf file every time you save. And as always, I like to hit save a bunch so I lose as little info as possible if my computer crashes or Inventor does. As long as you have the option to not preview the file after it is exported/saved, it doesn't slow your saving down too much. Other than that really, I don't have much else. I've thought of a few I might like to add or research how to do myself through macros and VBA, but can't seem to find the down time to work on it much. Any other little tools/add-ons you like to run with your Inventor? -
I use AutoCAD 2007 and program in VBA. Could you help with drawing cylinders in VBA. The "AddCylinder" draws only in WCS meaning I get cylinders in only one direction. I need cylinders to the UCS I set using the VBA program.
- 2 replies
-
- ucs
- addcylinder
-
(and 1 more)
Tagged with:
-
Hi, My VBA project reads coordinate file from field measurements of topographer and builds via some routines two classes: AllPoints (x,y) and AllLines (from x,y , to x,y). Seperating real points from reference points. I cannot seem to get a way to kick of the drawing command. Anybody some ideas? Preferebly a polyline with closed option. Thanx!
- 2 replies
-
- polygon
- autocad 2006
-
(and 1 more)
Tagged with:
-
Is there by any chance anyone who knows how to access magicad objects in VBA? (Magicad is a plugin for construction of heating, piping and ventilation....) I can find the objects as AcadEntitys, but don't know where to go from there! /Kalle
-
I need a way to select everything but the centerlines within a block. They extend beyond the part which I hope to find the actual envelope dimensions of. I will then iterate through the remaining parts to find the max/envelope dimensions. The issue is this block is in a document with many other objects (blocks, lines, points, etc.) so exploding is not ideal as it would be a pain to recollect the parts. Also opening a seperate file is too time consuming, this must be done within the file at hand. Is this even possible? EDIT: Oh! A little drilling, and you can easily and directly access a block within a document, then iterate through them as I mentioned above. No inception-style selection sets needed! Nice. Looks very roughly like this: Dim blkTestBlock As AcadBlock Set blkTestBlock = AutoCAD.Application.ActiveDocument.Blocks("ACT1") For Each ACADEntity in blkTestBlock If linetype="Continuous" then getboundingbox....blahblahblah
-
- selection set
- filters
-
(and 2 more)
Tagged with:
-
Importing Excel data and draw lines (Data is "From" "To" ponts of Line or length
pvsvprasadcivil posted a topic in AutoLISP, Visual LISP & DCL
Dear All my well wishers...please solve my typical problem..please..my data as below(From Excel) S.No. Length(m) From To Remarks 1. 10 11.5 soil 2. 13 14 soil 3. 10 11.5 concrete strata 4. 10 12 Bitumen Strata How to draw lines from above data(From Excel) by importing, using visual lisp.PLEASE RESPOND POSITIVELYY.PLZZZZ BAR CHAR INPUT DATA.xlsx GRAPH FINAL OUTPUT.dwg- 8 replies
-
- lisp
- import excel
-
(and 2 more)
Tagged with:
-
creatre Mleader in Pspace leader start with edge of 3d solid/3d block
ramanusu posted a topic in .NET, ObjectARX & VBA
Hi everbody, I need a help with Autocad 2011+ with VBA (Visual Basic for Application), I want to creatre Mleader in Pspace leader start with edge of 3d solid/3d block. Which classes should I use? Thanks for helps.... -
change viewports position (x and y cordinates)
alokmpatel posted a topic in AutoLISP, Visual LISP & DCL
Hello every one, i found thread about change height and width of particular one viewport. My current situation: I have 3 viewports. i want only one viewport at some specific coordinate (say x=100, y=200) and remain two viewports are are at other coordinate (say x=1000, y=2000) it is possible manually, by simply selecting 1st viewport and editing "Center X" and "Center Y" of their viewport property. if some one know than please help me... Alok -
Generally each settings in the Options dialog has an associated system variable. This gives us a way to programmatically access them. However, AMOPTIONS don't seem to have any associated system variables. Even the Preferences object doesn't seem to give them the access. What, then, is the way to access them using VBA?
- 4 replies
-
- options
- autocad mechanical
-
(and 1 more)
Tagged with:
-
Is there a way to create a lips program or a vba macro to offset a line on both sides, keep the source, then trim all the content between the two offset lines and delete them. Or is there a way to create the same effect around a MLeader? Something like the described on the attached imaged
-
I'm running AutoCad Architecture 2013 on Win7 64bit. Installed VBA enabler for Acad2013 64bit version. When start the simple code below: Sub Example_GetPoint() Dim retPnt As Variant retPnt = ThisDrawing.Utility.GetPoint(, "Enter a point: ") ... ... ... ... End Sub It hangs up at "GetPoint". I can't switch to the AutoCAD window to select anything. The only way to get control back is to go to taskbar, right-click the AutoCAD icon and try to close it, then click cancel, I will get control back in VBA Editor. The same thing happens with "SelectOnScreen". But if I run this macro from Autocad directly, everything is fine. Does anyone have same experience or any advice? Thanks a lot.
-
Hi guys, I'm new here and in programming also. I need to create a programm which should check a drawing. The check means, that we have 3 different layers: contour, axes and section. As you know all of them must have different lines thickness. So, let's imagine that thickness should be: 0,5mm 1mm ant 2mm. Is it possible to create such a program, which, when user selects any line or selects any layer in the drawing, my programm checks this solution and changes automatically thickness of the layer lines? If yes, how can I do it? any suggestions?
- 8 replies
-
- layer
- help wanted
-
(and 1 more)
Tagged with: