Jump to content

Search the Community

Showing results for tags 'excel'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

Categories

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

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

  1. Hi! Is there a way to use a clipping boundary on an OLE from excel? I've tried blocking it and then using xclip, but oddly it clips everything _except_ the OLE. Basically, I've got multiple tables I want to display throughout the drawing and I'd like them to be linked to a single excel, while still being embedded rather than linked to an external excel file. I've been able to use an excel OLE within blocks before to accomplish this for the same table repeated throughout a drawing, but I'm hitting a dead end for doing this with multiple tables. Thanks!
  2. Hey guys, I am writting a routine to read a excel file that contains a column with the number of the element, a column with the x's coordinate and a column with the y's coordinate. I need a way of making a loop to read whatever elements are filled by the excel's user and get this values in vectors so they can be used after. Is there anyway of doing that? Thank you very much!
  3. This seems to be a very widely asked question with many people wanting different solutions. After several days of searching I find myself asking the question here. I work for a small electrical design company. We work with many AutoCAD drawings which require transmittal back and forth to customers. With each set of drawings that we send, we send a document listing all the drawings (a drawing register). This is pretty common practice. Currently we have to manually input the drawing numbers, titles, revision numbers etc. in to an Excel spreadsheet template. What I would like to do is semi-automate this process, preferably using Excel's VBA, or at a later date MS Access. I have some experience in using VBA, accessing other xls files on the server and collating information, but have never used it to access an AutoCAD dwg file. In short, what I have/want to do is as follows: I have an Excel template that lists will list all the drawings for transmittal. I have hundreds of AutoCAD drawings which contain a title block with the following attributes: Drawing_number, Title_1, Title_2, Title_3, Revision (and more, but these are the main required attributes for the drawing register) I want to run the excel file, select (through the use of a browse file command, which I am familiar with) the drawings I wish to add to the list, extract the information contained in the above attributes, write this information to my desired cells in the drawing register. I am fairly competent at programming and trained in C, C#, C++ at university (a few years ago) so my understanding is okay. I am just struggling with acquiring the code to access AutoCAD attributes. My understanding is that I need to use a library to prevent me opening AutoCAD each time I read a file, but again I'm unsure of how to do this. I do not wish to extract the information from the AutoCAD files individually as this would be far too lengthy and I want to avoid the use of lisp as I wish to enclose the whole package of creating a drawing register for other users in the company who have very little/no experience of programming code. I would also like to avoid datalinks, this isn't an option, and I don't wish to be able to modify the content of the AutoCAD title block using Excel (unless this is a very simple addition, as it isn't required at this stage) Thank you in advance. Graham
  4. hi to everyone, You will find attached a txt file which contains coordinate points from a naca that i created with qblade. I want someone to help me with creating a program at inventor's api that will read this txt and then transfers the content to an excel file. thank you in advance Blade.zip
  5. 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!
  6. I am trying to write an autolisp program to insert a row of 20 blocks in a drawing, (one over the other), then insert attributes for each from a row in an Excel file. I am using Jeffrey Sanders' "GetCells" function. The Excel file is "RO-16.xlsx" Here's what I have done so far: (defun Addenters ( / cnt yval) (setq cnt 1) (setq yval 0) (setvar "osmode" 0) (load "getcells.lsp") (while ( ( (setq *doc* (vla-get-activedocument (vlax-get-acad-object))) (command "insert" "C:\\07509\\BD" (strcat "0," (itoa yval))"1" "1" "04" (getCellsFunction "C:\\07509\\RO-16.xlsx" "ALLOCATED" "K2") ) (setq cnt (1+ cnt)) (setq yval (+ 8 yval)) ) ) ) So the first attribute, "PLC" is read from cell K2 in the Excel file. There are 7 attributes altogether. Is there a more compact way to do this (with a list or array). I want to avoid having a long line (which is answering to the Autocad prompt for block attributes) which looks like: (getCellsFunction "C:\\07509\\RO-16.xlsx" "ALLOCATED" "L2"), (getCellsFunction "C:\\07509\\RO-16.xlsx" "ALLOCATED" "M2") and so on.
  7. Dear smarties I read a few articles here and there regarding a way to generate multiple drawings from an excel file, but no one had explained step by step on how to do it. So, I am lost half way. I am very new to this kind of things, but I will try to follow, so please go slow on me. here is what I want to fix: 1. I need to automatically generate 10 drawings both in dwg and pdf copied into a folder. 2. All the variables (VAR1 to VAR3) are stored in an excel file. refer to the attached files as an example. 3. I only need to create one original drawing, which will be used to generate all the 10 drawings. Please help EXCEL-VAR.xls ORIGINAL-DWG.dwg
  8. Dinochrome

    I drew a rectangle

    OK, It's more complicated than that... I'm working through a tutorial on linking parameters to an Inventor part. I have a spreadsheet set up to drive a regular box shape. My parameters are WIDTH, LENGTH, and HEIGHT. I am in the base sketch where I'd like to set d0 and d1 to WIDTH and LENGTH respectively. How do I find the two existing parameters please? I have looked both in the sketch and out on the workspace. If I try to add a dimension, it comes in as d3. The gentleman doing the video just magically clicks on the edge of the rectangle and d1 appears, ready to be edited. TIA Bill
  9. The overall goal is to reduce data entry. I have an excel file that has been special pasted into my Autodesk AutoCAD LT. I want to take information from individual cells and make them into fielded values. If you have follow-up questions, I will be happy to answer.
  10. Does anyone know a way or has a LISP where you could connect dynamic block parameter with an excel table? I know there is a way to insert a block at x,y,z coordinates (found a LISP for that some time ago, message me if you need it). I would like to add the parameter in that LISP where I could control the size(distance, rotation...) of the parameter.
  11. I'm trying to get LISP to automate the editing of a bunch of dynamic blocks for basic things like width and depth. I want to have all these values set up by model numbers in in an Excel spreadsheet. In order to accomplish this, I've used the code for "Set Dynamic Property Value" by Lee Mac and "GetExcel" by Terry Miller (thank you both so much for getting me this far). I have succeeded in getting LISP to manipulate dynamic blocks with Lee Mac's code, but only using hard numbers. I can also get Getexcel to return numbers from my .xls. But I can't get those Excel numbers into the dynamic block values. Here's how the code I came up with looks (the part that I wrote is at the bottom and is my attempt to get all the stuff above to work together): ;------------------------------------------------------------------------------- ; Program Name: GetExcel.lsp [GetExcel R4] ; Created By: Terry Miller (Email: [email="terrycadd@yahoo.com"]terrycadd@yahoo.com[/email]) ; (URL: [url]http://web2.airmail.net/terrycad[/url]) ; Date Created: 9-20-03 ; Function: Several functions to get and put values into Excel cells. ;------------------------------------------------------------------------------- ; Revision History ; Rev By Date Description ;------------------------------------------------------------------------------- ; 1 TM 9-20-03 Initial version ; 2 TM 8-20-07 Rewrote GetExcel.lsp and added several new sub-functions ; including ColumnRow, Alpha2Number and Number2Alpha written ; by Gilles Chanteau from Marseille, France. ; 3 TM 12-1-07 Added several sub-functions written by Gilles Chanteau ; including Cell-p, Row+n, and Column+n. Also added his ; revision of the PutCell function. ; 4 GC 9-20-08 Revised the GetExcel argument MaxRange$ to accept a nil ; and get the current region from cell A1. ;------------------------------------------------------------------------------- ; Overview of Main functions ;------------------------------------------------------------------------------- ; GetExcel - Stores the values from an Excel spreadsheet into *ExcelData@ list ; Syntax: (GetExcel ExcelFile$ SheetName$ MaxRange$) ; Example: (GetExcel "C:\\Folder\\Filename.xls" "Sheet1" "L30") ; GetCell - Returns the cell value from the *ExcelData@ list ; Syntax: (GetCell Cell$) ; Example: (GetCell "H15") ; Function example of usage: ; (defun c:Get-Example () ; (GetExcel "C:\\Folder\\Filename.xls" "Sheet1" "L30");<-- Edit Filename.xls ; (GetCell "H21");Or you can just use the global *ExcelData@ list ; );defun ;------------------------------------------------------------------------------- ; OpenExcel - Opens an Excel spreadsheet ; Syntax: (OpenExcel ExcelFile$ SheetName$ Visible) ; Example: (OpenExcel "C:\\Folder\\Filename.xls" "Sheet1" nil) ; PutCell - Put values into Excel cells ; Syntax: (PutCell StartCell$ Data$) or (PutCell StartCell$ DataList@) ; Example: (PutCell "A1" (list "GP093" 58.5 17 "Base" "3'-6 1/4\"")) ; CloseExcel - Closes Excel session ; Syntax: (CloseExcel ExcelFile$) ; Example: (CloseExcel "C:\\Folder\\Filename.xls") ; Function example of usage: ; (defun c:Put-Example () ; (OpenExcel "C:\\Folder\\Filename.xls" "Sheet1" nil);<-- Edit Filename.xls ; (PutCell "A1" (list "GP093" 58.5 17 "Base" "3'-6 1/4\""));Repeat as required ; (CloseExcel "C:\\Folder\\Filename.xls");<-- Edit Filename.xls ; (princ) ; );defun ;------------------------------------------------------------------------------- ; Note: Review the conditions of each argument in the function headings ;------------------------------------------------------------------------------- ; GetExcel - Stores the values from an Excel spreadsheet into *ExcelData@ list ; Arguments: 3 ; ExcelFile$ = Path and filename ; SheetName$ = Sheet name or nil for not specified ; MaxRange$ = Maximum cell ID range to include or nil to get the current region from cell A1 ; Syntax examples: ; (GetExcel "C:\\Temp\\Temp.xls" "Sheet1" "E19") = Open C:\Temp\Temp.xls on Sheet1 and read up to cell E19 ; (GetExcel "C:\\Temp\\Temp.xls" nil "XYZ123") = Open C:\Temp\Temp.xls on current sheet and read up to cell XYZ123 ;------------------------------------------------------------------------------- (defun GetExcel (ExcelFile$ SheetName$ MaxRange$ / Column# ColumnRow@ Data@ ExcelRange^ ExcelValue ExcelValue ExcelVariant^ MaxColumn# MaxRow# Range$ Row# Worksheet) (if (= (type ExcelFile$) 'STR) (if (not (findfile ExcelFile$)) (progn (alert (strcat "Excel file " ExcelFile$ " not found.")) (exit) );progn );if (progn (alert "Excel file not specified.") (exit) );progn );if (gc) (if (setq *ExcelApp% (vlax-get-object "Excel.Application")) (progn (alert "Close all Excel spreadsheets to continue!") (vlax-release-object *ExcelApp%)(gc) );progn );if (setq ExcelFile$ (findfile ExcelFile$)) (setq *ExcelApp% (vlax-get-or-create-object "Excel.Application")) (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Open ExcelFile$) (if SheetName$ (vlax-for Worksheet (vlax-get-property *ExcelApp% "Sheets") (if (= (vlax-get-property Worksheet "Name") SheetName$) (vlax-invoke-method Worksheet "Activate") );if );vlax-for );if (if MaxRange$ (progn (setq ColumnRow@ (ColumnRow MaxRange$)) (setq MaxColumn# (nth 0 ColumnRow@)) (setq MaxRow# (nth 1 ColumnRow@)) );progn (progn (setq CurRegion (vlax-get-property (vlax-get-property (vlax-get-property *ExcelApp% "ActiveSheet") "Range" "A1") "CurrentRegion") );setq (setq MaxRow# (vlax-get-property (vlax-get-property CurRegion "Rows") "Count")) (setq MaxColumn# (vlax-get-property (vlax-get-property CurRegion "Columns") "Count")) );progn );if (setq *ExcelData@ nil) (setq Row# 1) (repeat MaxRow# (setq Data@ nil) (setq Column# 1) (repeat MaxColumn# (setq Range$ (strcat (Number2Alpha Column#)(itoa Row#))) (setq ExcelRange^ (vlax-get-property *ExcelApp% "Range" Range$)) (setq ExcelVariant^ (vlax-get-property ExcelRange^ 'Value)) (setq ExcelValue (vlax-variant-value ExcelVariant^)) (setq ExcelValue (cond ((= (type ExcelValue) 'INT) (itoa ExcelValue)) ((= (type ExcelValue) 'REAL) (rtosr ExcelValue)) ((= (type ExcelValue) 'STR) (vl-string-trim " " ExcelValue)) ((/= (type ExcelValue) 'STR) "") );cond );setq (setq Data@ (append Data@ (list ExcelValue))) (setq Column# (1+ Column#)) );repeat (setq *ExcelData@ (append *ExcelData@ (list Data@))) (setq Row# (1+ Row#)) );repeat (vlax-invoke-method (vlax-get-property *ExcelApp% "ActiveWorkbook") 'Close :vlax-False) (vlax-invoke-method *ExcelApp% 'Quit) (vlax-release-object *ExcelApp%)(gc) (setq *ExcelApp% nil) *ExcelData@ );defun GetExcel ;------------------------------------------------------------------------------- ; GetCell - Returns the cell value from the *ExcelData@ list ; Arguments: 1 ; Cell$ = Cell ID ; Syntax example: (GetCell "E19") = value of cell E19 ;------------------------------------------------------------------------------- (defun GetCell (Cell$ / Column# ColumnRow@ Return Row#) (setq ColumnRow@ (ColumnRow Cell$)) (setq Column# (1- (nth 0 ColumnRow@))) (setq Row# (1- (nth 1 ColumnRow@))) (setq Return "") (if *ExcelData@ (if (and (>= (length *ExcelData@) Row#)(>= (length (nth 0 *ExcelData@)) Column#)) (setq Return (nth Column# (nth Row# *ExcelData@))) );if );if Return );defun GetCell ;------------------------------------------------------------------------------- ; OpenExcel - Opens an Excel spreadsheet ; Arguments: 3 ; ExcelFile$ = Excel filename or nil for new spreadsheet ; SheetName$ = Sheet name or nil for not specified ; Visible = t for visible or nil for hidden ; Syntax examples: ; (OpenExcel "C:\\Temp\\Temp.xls" "Sheet2" t) = Opens C:\Temp\Temp.xls on Sheet2 as visible session ; (OpenExcel "C:\\Temp\\Temp.xls" nil nil) = Opens C:\Temp\Temp.xls on current sheet as hidden session ; (OpenExcel nil "Parts List" nil) = Opens a new spreadsheet and creates a Part List sheet as hidden session ;------------------------------------------------------------------------------- (defun OpenExcel (ExcelFile$ SheetName$ Visible / Sheet$ Sheets@ Worksheet) (if (= (type ExcelFile$) 'STR) (if (findfile ExcelFile$) (setq *ExcelFile$ ExcelFile$) (progn (alert (strcat "Excel file " ExcelFile$ " not found.")) (exit) );progn );if (setq *ExcelFile$ "") );if (gc) (if (setq *ExcelApp% (vlax-get-object "Excel.Application")) (progn (alert "Close all Excel spreadsheets to continue!") (vlax-release-object *ExcelApp%)(gc) );progn );if (setq *ExcelApp% (vlax-get-or-create-object "Excel.Application")) (if ExcelFile$ (if (findfile ExcelFile$) (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Open ExcelFile$) (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Add) );if (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Add) );if (if Visible (vla-put-visible *ExcelApp% :vlax-true) );if (if (= (type SheetName$) 'STR) (progn (vlax-for Sheet$ (vlax-get-property *ExcelApp% "Sheets") (setq Sheets@ (append Sheets@ (list (vlax-get-property Sheet$ "Name")))) );vlax-for (if (member SheetName$ Sheets@) (vlax-for Worksheet (vlax-get-property *ExcelApp% "Sheets") (if (= (vlax-get-property Worksheet "Name") SheetName$) (vlax-invoke-method Worksheet "Activate") );if );vlax-for (vlax-put-property (vlax-invoke-method (vlax-get-property *ExcelApp% "Sheets") "Add") "Name" SheetName$) );if );progn );if (princ) );defun OpenExcel ;------------------------------------------------------------------------------- ; PutCell - Put values into Excel cells ; Arguments: 2 ; StartCell$ = Starting Cell ID ; Data@ = Value or list of values ; Syntax examples: ; (PutCell "A1" "PART NUMBER") = Puts PART NUMBER in cell A1 ; (PutCell "B3" '("Dim" 7.5 "9.75")) = Starting with cell B3 put Dim, 7.5, and 9.75 across ;------------------------------------------------------------------------------- (defun PutCell (StartCell$ Data@ / Cell$ Column# ExcelRange Row#) (if (= (type Data@) 'STR) (setq Data@ (list Data@)) ) (setq ExcelRange (vlax-get-property *ExcelApp% "Cells")) (if (Cell-p StartCell$) (setq Column# (car (ColumnRow StartCell$)) Row# (cadr (ColumnRow StartCell$)) );setq (if (vl-catch-all-error-p (setq Cell$ (vl-catch-all-apply 'vlax-get-property (list (vlax-get-property *ExcelApp% "ActiveSheet") "Range" StartCell$)) );setq );vl-catch-all-error-p (alert (strcat "The cell ID \"" StartCell$ "\" is invalid.")) (setq Column# (vlax-get-property Cell$ "Column") Row# (vlax-get-property Cell$ "Row") );setq );if );if (if (and Column# Row#) (foreach Item Data@ (vlax-put-property ExcelRange "Item" Row# Column# (vl-princ-to-string Item)) (setq Column# (1+ Column#)) );foreach );if (princ) );defun PutCell ;------------------------------------------------------------------------------- ; CloseExcel - Closes Excel spreadsheet ; Arguments: 1 ; ExcelFile$ = Excel saveas filename or nil to close without saving ; Syntax examples: ; (CloseExcel "C:\\Temp\\Temp.xls") = Saveas C:\Temp\Temp.xls and close ; (CloseExcel nil) = Close without saving ;------------------------------------------------------------------------------- (defun CloseExcel (ExcelFile$ / Saveas) (if ExcelFile$ (if (= (strcase ExcelFile$) (strcase *ExcelFile$)) (if (findfile ExcelFile$) (vlax-invoke-method (vlax-get-property *ExcelApp% "ActiveWorkbook") "Save") (setq Saveas t) );if (if (findfile ExcelFile$) (progn (vl-file-delete (findfile ExcelFile$)) (setq Saveas t) );progn (setq Saveas t) );if );if );if (if Saveas (vlax-invoke-method (vlax-get-property *ExcelApp% "ActiveWorkbook") "SaveAs" ExcelFile$ -4143 "" "" :vlax-false :vlax-false nil );vlax-invoke-method );if (vlax-invoke-method (vlax-get-property *ExcelApp% "ActiveWorkbook") 'Close :vlax-False) (vlax-invoke-method *ExcelApp% 'Quit) (vlax-release-object *ExcelApp%)(gc) (setq *ExcelApp% nil *ExcelFile$ nil) (princ) );defun CloseExcel ;------------------------------------------------------------------------------- ; ColumnRow - Returns a list of the Column and Row number ; Function By: Gilles Chanteau from Marseille, France ; Arguments: 1 ; Cell$ = Cell ID ; Syntax example: (ColumnRow "ABC987") = '(731 987) ;------------------------------------------------------------------------------- (defun ColumnRow (Cell$ / Column$ Char$ Row#) (setq Column$ "") (while (< 64 (ascii (setq Char$ (strcase (substr Cell$ 1 1)))) 91) (setq Column$ (strcat Column$ Char$) Cell$ (substr Cell$ 2) );setq );while (if (and (/= Column$ "") (numberp (setq Row# (read Cell$)))) (list (Alpha2Number Column$) Row#) '(1 1);default to "A1" if there's a problem );if );defun ColumnRow ;------------------------------------------------------------------------------- ; Alpha2Number - Converts Alpha string into Number ; Function By: Gilles Chanteau from Marseille, France ; Arguments: 1 ; Str$ = String to convert ; Syntax example: (Alpha2Number "ABC") = 731 ;------------------------------------------------------------------------------- (defun Alpha2Number (Str$ / Num#) (if (= 0 (setq Num# (strlen Str$))) 0 (+ (* (- (ascii (strcase (substr Str$ 1 1))) 64) (expt 26 (1- Num#))) (Alpha2Number (substr Str$ 2)) );+ );if );defun Alpha2Number ;------------------------------------------------------------------------------- ; Number2Alpha - Converts Number into Alpha string ; Function By: Gilles Chanteau from Marseille, France ; Arguments: 1 ; Num# = Number to convert ; Syntax example: (Number2Alpha 731) = "ABC" ;------------------------------------------------------------------------------- (defun Number2Alpha (Num# / Val#) (if (< Num# 27) (chr (+ 64 Num#)) (if (= 0 (setq Val# (rem Num# 26))) (strcat (Number2Alpha (1- (/ Num# 26))) "Z") (strcat (Number2Alpha (/ Num# 26)) (chr (+ 64 Val#))) );if );if );defun Number2Alpha ;------------------------------------------------------------------------------- ; Cell-p - Evaluates if the argument Cell$ is a valid cell ID ; Function By: Gilles Chanteau from Marseille, France ; Arguments: 1 ; Cell$ = String of the cell ID to evaluate ; Syntax examples: (Cell-p "B12") = t, (Cell-p "BT") = nil ;------------------------------------------------------------------------------- (defun Cell-p (Cell$) (and (= (type Cell$) 'STR) (or (= (strcase Cell$) "A1") (not (equal (ColumnRow Cell$) '(1 1))) );or );and );defun Cell-p ;------------------------------------------------------------------------------- ; Row+n - Returns the cell ID located a number of rows from cell ; Function By: Gilles Chanteau from Marseille, France ; Arguments: 2 ; Cell$ = Starting cell ID ; Num# = Number of rows from cell ; Syntax examples: (Row+n "B12" 3) = "B15", (Row+n "B12" -3) = "B9" ;------------------------------------------------------------------------------- (defun Row+n (Cell$ Num#) (setq Cell$ (ColumnRow Cell$)) (strcat (Number2Alpha (car Cell$)) (itoa (max 1 (+ (cadr Cell$) Num#)))) );defun Row+n ;------------------------------------------------------------------------------- ; Column+n - Returns the cell ID located a number of columns from cell ; Function By: Gilles Chanteau from Marseille, France ; Arguments: 2 ; Cell$ = Starting cell ID ; Num# = Number of columns from cell ; Syntax examples: (Column+n "B12" 3) = "E12", (Column+n "B12" -1) = "A12" ;------------------------------------------------------------------------------- (defun Column+n (Cell$ Num#) (setq Cell$ (ColumnRow Cell$)) (strcat (Number2Alpha (max 1 (+ (car Cell$) Num#))) (itoa (cadr Cell$))) );defun Column+n ;------------------------------------------------------------------------------- ; rtosr - Used to change a real number into a short real number string ; stripping off all trailing 0's. ; Arguments: 1 ; RealNum~ = Real number to convert to a short string real number ; Returns: ShortReal$ the short string real number value of the real number. ;------------------------------------------------------------------------------- (defun rtosr (RealNum~ / DimZin# ShortReal$) (setq DimZin# (getvar "DIMZIN")) (setvar "DIMZIN" (setq ShortReal$ (rtos RealNum~ 2 ) (setvar "DIMZIN" DimZin#) ShortReal$ );defun rtosr ;------------------------------------------------------------------------------- (princ);End of GetExcel.lsp ;;;THIS IS THE ORIGINAL CODE PULLED FROM [url]http://www.cadtutor.net/forum/archive/index.php/t-89036.html?[/url] ;;;top half not used....just the setdynpropvalue (defun c:test ( / blk ) (if (and (setq blk (car (entsel "\nSelect dynamic block: "))) (setq blk (vlax-ename->vla-object blk)) (= "AcDbBlockReference" (vla-get-objectname blk)) (= :vlax-true (vla-get-isdynamicblock blk)) ) (LM:setdynpropvalue blk "distance1" 1.0) ) (princ) ) ;; Set Dynamic Block Property Value - Lee Mac ;; Modifies the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; val - [any] New value for property ;; Returns: [any] New value if successful, else nil (defun LM:setdynpropvalue ( blk prp val ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x)))) (cond (val) (t)) ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) (vl-load-com) (princ) ;;;;;;;;;;;; ;;;Test for plugging excel numbers into dynamic blocks (defun c:dynant () (GetExcel "C:\\Users\\eli.garcia\\Desktop\\getexceltest.xls" "Sheet1" "B5");<-- Edit Filename.xls (setq DA (GetCell "B2"));Or you can just use the global *ExcelData@ list ( / blk ) (if (and (setq blk (car (entsel "\nSelect dynamic block: "))) (setq blk (vlax-ename->vla-object blk)) (= "AcDbBlockReference" (vla-get-objectname blk)) (= :vlax-true (vla-get-isdynamicblock blk)) ) ((LM:setdynpropvalue blk "depth" DA) (LM:setdynpropvalue blk "half-width" DA)) ) (princ) ) ) I've attempted to attached a text file of all of this, but apparently that tool is broken right now, thus the huge post. I'm pretty close to being a novice at this, but I'm learning in the little time my work allows. My thought is that the way I used SETQ is wrong or that SETQ can't work with Excel like this. Please help.
  12. Does anybody know how to retrieve / handle this? (vlax-get-property rangeobject 'ColumnWidth) i dont know how the rangeobject must look like thanx in advance
  13. 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,
  14. Hi all, A company I previously worked for had a tool that could export a .csv file out of a sheetset that contained all the attributes associated with that sheet set for different drawings etc which could then be edited in excel and then imported. As you imported it, it updated all the sheetset & drawings with the new values. The exporting part is the easy bit, does anyone know how to import it in a way that it can then overwrite the sheetset...? PS... I'm not a ACAD programmer by any stretch so existing tools would be handy or simple coding. cheers.
  15. 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
  16. Hi, hello everyone. i am new to autolisp. i need a routine that can calculate distance between two points and write it down to active cell of active workbook. (wherever selected in excel). Is it possible? will be very helpful to me. Thanks
  17. Back into the world of AutoCAD after a 20 year absence. When exporting dynamic block parameter data to Excel using the wizard, all data ends up as text (ex: 3'6 1/2") which is useless for using within Excel formulas. Is there a way around this other than changing the units to decimal before I extract the data and then converting text back to numeric in Excel?
  18. Does anyone know how to achieve this? I have a series of blocks with attributes in Autocad. Attribute is a number (from 1 to 500). Each of the blocks represents a single machine with serial number 1-500 on it. When I place a new block of machine (I do it by copy/paste from the nearby block) I just change the attribute value manually. Now, as a separate file I have excel sheet with two columns: COLUMN A -> serial number of machines (1-500) COLUMN B -> type of machine (e.g. TYPE-1, TYPE-2, TYPE-3...), around 8 types in total Is it possible to make a block with two values in it (attributes) and when a value of machine serial number in position 1 is changed it will look the excel file and return the machine type in position 2. Something like VLOOKUP excel formula, but in AUTOCAD. For example if EXCEL is: COLUMN A / COLUMN B 250 / TYPE-3 251 / TYPE-5 Than the change in AutoCAD attributes in position 1 and 2 is like this: ATT-1: 250 ATT-2: TYPE-3 if I manually change ATT-1 to value 251, then: ATT-1: 251 ATT-2: TYPE-3
  19. Hi Everyone! I am having a bit of a dilemma. I am trying to find out (not sure what to search for) if it is possible to take data from an OLE and be able to capture it into an ACCESS database. I have an example of what needs to be pulled if this is even possible.
  20. Is it possible? I have a colleague who uses InRoads. (I'll use C3D language here. . . ) He is able to select an assembly (in a corridor) based on input in an Excel spreadsheet. Is there anyway to import corridor Start and End stations? Is there anyway to dictate a region's assembly based on Excel data (even a copy/paste solution)?
  21. Hi, I have several drawings that each include (1) a layout containing a viewport showing drainage areas & an x-referenced survey and (2) a spreadsheet with drainage calculations. Recently a problem has developed such that the x-referenced survey is not plotting correctly on the layouts that contain the spreadsheet. At first I thought it was a fluke with one drawing, but then it started happening on all my drawings, even ones that had previously plotted fine. Here are the details: 1) The x-reference plots fine in all the layouts within the drawing except the one that contains the spreadsheet. 2) The spreadsheet is put into the drawing by selecting the cells in Excel, copying, going to paperspace in Autocad, and pasting the cells in. 3) I have two methods for creating pdfs in Civil 3D 2008. First method: go to the "Adobe PDF" menu and select the "Convert to Adobe PDF" option. This method plots everything fine except the xreference. Second method: Go to "File" -> "Plot" and use the plotter "DWG to PDF.pc3". This method plots the xreference, but the text in the titleblock and the spreadsheet is all garbled and fuzzy. Any suggestions? Is there some system variable or AutoCAD setting that would cause this?
  22. Hello all, I am attempting to extract a list of all blocks and their attributed text into excel (from which to build a BOM). Using the dataextraction commands works, but there are a lot of button clicks (aka places where users could get confused or click the wrong thing). I tried using -dataextraction, but for some reason using the command line version does not let me search for objects in the current drawing. Opening the extraction wizard confirms this - whenever I load a template, even if I selected "also search in current drawing" when making it, it's unchecked by default. Something like Lee Mac's program MacAtt might work, but it doesn't have a command line version. I've also tried using the code from this thread http://www.cadtutor.net/forum/showthread.php?50663-Data-Extraction but upon running it, I get "error: quit / exit abort" I'm thinking there is a way to do what I want through the "ATTEXT" command, but every time I try to use it, it says "0 records in extract file" and the output file is blank. Anyone have ideas about what else I can try?
  23. I have an autocad drawing with so many light fixtures with all different names.Now we have to change all those names, i already have an excel sheet containing two columns with first one containing "name in drawing" and second one containing respective "new name". Is there any way to replace the names in cad file using that excel sheet.i just dont want to do all those thousand rename manually ...please some cad-guru help me
  24. Hello Everyone, I'm using AutoCad 2014 and have Microsoft office 2007. I use attributes in every drawing. Most have identifications as 1-01 which stands for Floor 1-Item #01 or 3-27 which stands for Floor 3-Item#27. When I use the data extraction, I extract it to the drawing, everything is correct at this point. Then export to a CSV file. If I open the CSV file in Excel all of my attributes turn into dates 1-Jan or 27-Mar. If I try to turn the column back to general or text it becomes some 5 digit number. Is there a way to export the data into excel but it keep the formating of the data in Cad?
  25. Hi all, I'm currently using AutoCAD 2014. I'm use to using AutoCAD but have never used VBA or AutoLISP before. Really just found out about them from doing some research on the internet and hoping for some help with my dilemma. I have a floor plan already drawn and each individual room already has a separate hatch created as a block with a unique identifier. What I would like to be able to do is somehow make the layer of the block change to represent the percent completion of each room. I would ideally like to just be able to make an Excel spreadsheet that contains in column A the block title like Kitchen, Bath Room 1, Living Room, etc. and column B would contain the layer I want to move it to. So when I change column B from 20 to 30 the layer updates automatically. A couple different people will be inputting to the spreadsheet which is why I want it to be able to the update automatically when needed. My floor plan contains about 60 different spaces (blocks) and has about 10 different colors (layers) to represent the percent completes. I'm not really sure how to go about this but I'm very much willing to learn. Eventually the drawing will grow to have over 300 individual blocks and around 12 layers. So you can see the amount of effort it would save versus selecting each block and changing it's layer individually. Thanks, JMB
×
×
  • Create New...