fcfcadd Posted September 1, 2010 Posted September 1, 2010 I want to know if I can Link a line to an Autocad Table or even excel. I want to be able to change the length of the line and have the table or excel automatically update. I've tried the Data Extraction tool but that doesn't update with the line. Quote
BlackBox Posted September 1, 2010 Posted September 1, 2010 Use a Visual LISP object reactor, where (as an example) :vlr-modified is your object event, and use the callback function to update your table or excel file. Quote
fcfcadd Posted September 1, 2010 Author Posted September 1, 2010 I don't know vlisp. Do I have to create a link between autocad and excel first then create the table? Quote
BlackBox Posted September 1, 2010 Posted September 1, 2010 I don't know vlisp. Do I have to create a link between autocad and excel first then create the table? This can be done, but without your knowing Visual LISP, this may not be as easy as it sounds. Could you post a sample table, so I can better evaluate just how difficult this may be? Are you adept at any other programming languages, by chance? If not, it may be better to simply point you to some reference material for you to do some vlax-homework. Maybe one of the guru's will come along with yet, another brilliant, simpler solution, that I may have overlooked...? Quote
lpseifert Posted September 1, 2010 Posted September 1, 2010 A link to Excel isn't necessary, you can create the table in acad directly from the DataExtraction wizard. Although it doesn't provide for an 'Automatic' update, changing the values of the sys var DXEVAL will let you know an update is due. Quote
fcfcadd Posted September 1, 2010 Author Posted September 1, 2010 I don't have anything created yet. What I am trying to do is have AutoCAD create a BOM based on specific lines I select and have it LIVE. If I change the lines length the BOM updates per that change. I first need to know how to create that link between the line and a table or excel. I know some lisp but I don't want a lisp a vlips routine to do this. I guess the question would be then is can AuotCAD do this? I know how to create an excel file and have in brought into AutoCAD and have it update back and forth. Quote
lpseifert Posted September 1, 2010 Posted September 1, 2010 Use a Visual LISP object reactor, where (as an example) :vlr-modified is your object event, and use the callback function to update your table or excel file. What callback function would you use to update a table? Quote
lpseifert Posted September 1, 2010 Posted September 1, 2010 I don't have anything created yet. What I am trying to do is have AutoCAD create a BOM based on specific lines I select and have it LIVE. If I change the lines length the BOM updates per that change. I first need to know how to create that link between the line and a table or excel. I know some lisp but I don't want a lisp a vlips routine to do this. I guess the question would be then is can AuotCAD do this? I know how to create an excel file and have in brought into AutoCAD and have it update back and forth. I don't think there is a 'Live' option- updates need to done manually (unless it's done by programing). Run through the DataExtraction Wizard- use the 'Select objects...' option on page 2 to select the lines. I think you'll figure it out, it may take a couple of tries. Quote
BlackBox Posted September 1, 2010 Posted September 1, 2010 What callback function would you use to update a table? I'd use a callback function, where the given list argument would be used to conditionally update said table. If you're asking how I would 'update' the table, I use this routine to find out what properties, and methods are available to a specific entity: (defun c:TEST (/ eName) (vl-load-com) (if (setq eName (car (entsel "\n >> Select object to dump contents: "))) (progn (vlax-dump-object (vlax-ename->vla-object eName) T) (textpage))) (princ)) AutoCAD Table properties and methods: ; IAcadTable2: IAcadTable2 Interface ; Property values: ; AllowManualHeights = 0 ; AllowManualPositions = 0 ; Application (RO) = #<VLA-OBJECT IAcadApplication 00cdb528> ; BreaksEnabled = 0 ; BreakSpacing = 0.99 ; Columns = 4 ; ColumnWidth (RO) = ...Indexed contents not shown... ; Direction = (1.0 0.0 0.0) ; Document (RO) = #<VLA-OBJECT IAcadDocument 015c59d0> ; EnableBreak (RO) = ...Indexed contents not shown... ; FlowDirection = 0 ; Handle (RO) = "1F5FD" ; HasExtensionDictionary (RO) = 0 ; HasSubSelection (RO) = 0 ; HeaderSuppressed = 0 ; Height = 1.53333 ; HorzCellMargin = 0.06 ; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 1a581f0c> ; InsertionPoint = (181.685 56.1103 0.0) ; Layer = "0" ; Linetype = "ByLayer" ; LinetypeScale = 1.0 ; Lineweight = -1 ; Material = "ByLayer" ; MinimumTableHeight (RO) = 1.53333 ; MinimumTableWidth (RO) = 1.48 ; ObjectID (RO) = 2128209832 ; ObjectName (RO) = "AcDbTable" ; OwnerID (RO) = 2128170264 ; PlotStyleName = "ByLayer" ; RegenerateTableSuppressed = 0 ; RepeatBottomLabels = 0 ; RepeatTopLabels = 0 ; RowHeight (RO) = ...Indexed contents not shown... ; Rows = 4 ; StyleName = "Standard" ; TableBreakFlowDirection = 1 ; TableBreakHeight = 0.0 ; TableStyleOverrides (RO) = nil ; TitleSuppressed = 0 ; TrueColor = #<VLA-OBJECT IAcadAcCmColor 1a1ad4e0> ; VertCellMargin = 0.06 ; Visible = -1 ; Width = 1.2 ; Methods supported: ; ArrayPolar (3) ; ArrayRectangular (6) ; ClearSubSelection () ; ClearTableStyleOverrides (1) ; Copy () ; CreateContent (3) ; Delete () ; DeleteCellContent (2) ; DeleteColumns (2) ; DeleteContent (2) ; DeleteRows (2) ; EnableMergeAll (3) ; FormatValue (4) ; GenerateLayout () ; GetAlignment (1) ; GetAttachmentPoint (2) ; GetAutoScale (2) ; GetAutoScale2 (3) ; GetBackgroundColor (1) ; GetBackgroundColorNone (1) ; GetBlockAttributeValue (3) ; GetBlockAttributeValue2 (4) ; GetBlockRotation (2) ; GetBlockScale (2) ; GetBlockTableRecordId (2) ; GetBlockTableRecordId2 (3) ; GetBoundingBox (2) ; GetBreakHeight (1) ; GetCellAlignment (2) ; GetCellBackgroundColor (2) ; GetCellBackgroundColorNone (2) ; GetCellContentColor (2) ; GetCellDataType (4) ; GetCellExtents (3) ; GetCellFormat (2) ; GetCellGridColor (3) ; GetCellGridLineWeight (3) ; GetCellGridVisibility (3) ; GetCellState (2) ; GetCellStyle (2) ; GetCellStyleOverrides (2) ; GetCellTextHeight (2) ; GetCellTextStyle (2) ; GetCellType (2) ; GetCellValue (2) ; GetColumnName (1) ; GetColumnWidth (1) ; GetContentColor (1) ; GetContentColor2 (3) ; GetContentLayout (2) ; GetContentType (2) ; GetCustomData (4) ; GetDataFormat (3) ; GetDataType (3) ; GetDataType2 (5) ; GetExtensionDictionary () ; GetFieldId (2) ; GetFieldId2 (3) ; GetFormat (1) ; GetFormula (3) ; GetGridColor (2) ; GetGridColor2 (3) ; GetGridDoubleLineSpacing (3) ; GetGridLineStyle (3) ; GetGridLinetype (3) ; GetGridLineWeight (2) ; GetGridLineWeight2 (3) ; GetGridVisibility (2) ; GetGridVisibility2 (3) ; GetHasFormula (3) ; GetMargin (3) ; GetMinimumColumnWidth (1) ; GetMinimumRowHeight (1) ; GetOverride (3) ; GetRotation (3) ; GetRowHeight (1) ; GetRowType (1) ; GetScale (3) ; GetSubSelection (4) ; GetText (2) ; GetTextHeight (1) ; GetTextHeight2 (3) ; GetTextRotation (2) ; GetTextString (3) ; GetTextStyle (1) ; GetTextStyle2 (3) ; GetValue (3) ; GetXData (3) ; Highlight (1) ; HitTest (4) ; InsertColumns (3) ; InsertColumnsAndInherit (3) ; InsertRows (3) ; InsertRowsAndInherit (3) ; IntersectWith (2) ; IsContentEditable (2) ; IsEmpty (2) ; IsFormatEditable (2) ; IsMergeAllEnabled (2) ; IsMergedCell (6) ; MergeCells (4) ; Mirror (2) ; Mirror3D (3) ; Move (2) ; MoveContent (4) ; RecomputeTableBlock (1) ; RemoveAllOverrides (2) ; ReselectSubRegion () ; ResetCellValue (2) ; Rotate (2) ; Rotate3D (3) ; ScaleEntity (2) ; Select ( ; SelectSubRegion (10) ; SetAlignment (2) ; SetAutoScale (3) ; SetAutoScale2 (4) ; SetBackgroundColor (2) ; SetBackgroundColorNone (2) ; SetBlockAttributeValue (4) ; SetBlockAttributeValue2 (5) ; SetBlockRotation (3) ; SetBlockScale (3) ; SetBlockTableRecordId (4) ; SetBlockTableRecordId2 (5) ; SetBreakHeight (2) ; SetCellAlignment (3) ; SetCellBackgroundColor (3) ; SetCellBackgroundColorNone (3) ; SetCellContentColor (3) ; SetCellDataType (4) ; SetCellFormat (3) ; SetCellGridColor (4) ; SetCellGridLineWeight (4) ; SetCellGridVisibility (4) ; SetCellState (3) ; SetCellStyle (3) ; SetCellTextHeight (3) ; SetCellTextStyle (3) ; SetCellType (3) ; SetCellValue (3) ; SetCellValueFromText (4) ; SetColumnName (2) ; SetColumnWidth (2) ; SetContentColor (2) ; SetContentColor2 (4) ; SetContentLayout (3) ; SetCustomData (4) ; SetDataFormat (4) ; SetDataType (3) ; SetDataType2 (5) ; SetFieldId (3) ; SetFieldId2 (5) ; SetFormat (2) ; SetFormula (4) ; SetGridColor (3) ; SetGridColor2 (4) ; SetGridDoubleLineSpacing (4) ; SetGridLineStyle (4) ; SetGridLinetype (4) ; SetGridLineWeight (3) ; SetGridLineWeight2 (4) ; SetGridVisibility (3) ; SetGridVisibility2 (4) ; SetMargin (4) ; SetOverride (4) ; SetRotation (4) ; SetRowHeight (2) ; SetScale (4) ; SetSubSelection (4) ; SetText (3) ; SetTextHeight (2) ; SetTextHeight2 (4) ; SetTextRotation (3) ; SetTextString (4) ; SetTextStyle (2) ; SetTextStyle2 (4) ; SetToolTip (3) ; SetValue (4) ; SetValueFromText (5) ; SetXData (2) ; TransformBy (1) ; UnmergeCells (4) ; Update () Command: Quote
lpseifert Posted September 1, 2010 Posted September 1, 2010 (edited) So what is your answer? Are you trying to say the function/method you would use is Update? I notice in ActiveX Help there is an UpdateAllDataLinks method for a Table object, although it's not listed as a method for the Table object (as shown in your dump) never mind about UpdateAllDataLinks... see here http://blog.jtbworld.com/2009/02/table-object-api-not-for-vba-or-visual.html Edited September 1, 2010 by lpseifert Quote
BlackBox Posted September 1, 2010 Posted September 1, 2010 (edited) So what is your answer?... Geez, Larry... I don't know about you, but I'm at work. I'm SO sorry that I've not made the time to write a routine which satiates you, Sir. ... Are you trying to say the function/method you would use is Update? ... I can see how my use of 'update' may have been confusing, allow me to clarify... I meant programmatically speaking. As for your question, I'm not adept at using the update method, so I'm going to go with no. More specifically, and this may not be the most efficient solution, what I had in mind was to write a callback function which would (obviously after the line object has been modified) extract the OPs needed data from the line entity (i.e., length, etc.) and compare that current value to the value listed in an associated table cell. If that current value is different, then the cell's contents would be overwritten with the current value. [edit] I'd specifically attempt to use the GetText, and SetText methods. (GetValue, and SetValue were incorrect) Adding some sort of Object Data (OD) to the table may be necessary, for the reactor's callback function to identify the table within the drawing as well. For that I'd consider using the ade_od* functions. [/edit] ... I notice in ActiveX Help there is an UpdateAllDataLinks method for a Table object, although it's not listed as a method for the Table object (as shown in your dump) As for why the UpdateAllDataLinks method was not listed, I am unsure. I think it might have something to do with the T in my vlax-dump-object statement...? I see you've edited your post, but again, I have not made time to read it yet. Edited September 1, 2010 by BlackBox Clarification Quote
fcfcadd Posted September 1, 2010 Author Posted September 1, 2010 So how does any of this help me in finding out if AutoCAD can link this information Quote
lpseifert Posted September 1, 2010 Posted September 1, 2010 Geez, Larry... I don't know about you, but I'm at work. I'm SO sorry that I've not made the time to write a routine which satiates you, Sir. I didn't mean to sound demanding... Trust me, I don't want you to write me a routine. It seemed from your earlier post that you knew what function/method could be used to update a linked table; that's all I wanted to know. I didn't expect a dump of a table, but maybe somebody can learn from it. Quote
lpseifert Posted September 1, 2010 Posted September 1, 2010 So how does any of this help me in finding out if AutoCAD can link this information See post #8 Quote
fcfcadd Posted September 1, 2010 Author Posted September 1, 2010 I don't think there is a 'Live' option- updates need to done manually (unless it's done by programing).Run through the DataExtraction Wizard- use the 'Select objects...' option on page 2 to select the lines. I think you'll figure it out, it may take a couple of tries. I have ran through and have been using the Data Extraction Tool and it keeps having it's issues. For one when you select all the lines you want if does not "Combine" lines that are the same length. Also there is no link between the line and the data extracted so there for the it's worthless to me to extract the data when it's not updateable other than manually. I can probably deal with having to update it manually if the information extracted is linked in some way. Quote
BlackBox Posted September 1, 2010 Posted September 1, 2010 (edited) I didn't mean to sound demanding... Trust me, I don't want you to write me a routine.It seemed from your earlier post that you knew what function/method could be used to update a linked table; that's all I wanted to know. I didn't expect a dump of a table, but maybe somebody can learn from it. Maybe I took your comments the wrong way. I'm not here to argue, I'm here to try an help... and learn a great deal at the same time. Nothing more. So how does any of this help me in finding out if AutoCAD can link this information This is a better example of what I meant by programmatically updating the table: (defun c:TBLMOD (/ table tableObj) (vl-load-com) (if (setq table (car (entsel "\n >> Select a table: "))) (progn (setq tableObj (vlax-ename->vla-object table)) (vla-settext tableObj 2 1 "This is a Test"))) (princ)) Note - In my testing, I used an AutoCAD table, with 4 rows and 4 columns. Now, the callback function would happen near instantaneously (milleseconds?) to the user, and would give the illusion of 'Live' updating. ... Make sense? Edited September 1, 2010 by BlackBox Added (vl-load-com) Quote
bass_mark00 Posted September 1, 2010 Posted September 1, 2010 A method you can use to do this is to set up FIELDS. 1 - Set up your table and double click inside a cell 2 - Click on the INSERT FIELD button on the TEXT FORMATTING box which pops up 3 - You'll then get a window called FIELD and you'll need to choose OBJECT from the dropdown in the first column 4 - Use the SELECT object button at the top of the second column and click on your line with the pickbox 5 - Choose the LENGTH property from the list 6 - Choose your length format in the third column The length of the line will then show up in the table cell. Change the length of the line, REGEN ALL and the length updates in the table. If you'd like me to send you a basic example drawing let me know. You can also use this technique to link areas to polylines. Mark Quote
fcfcadd Posted September 1, 2010 Author Posted September 1, 2010 Does this work if the table is not in the drawing where the lines are. In other words the way I have it setup is the drawing is xrefed into another drawing where the bom is. Does the table have to be in the same drawing? Quote
bass_mark00 Posted September 1, 2010 Posted September 1, 2010 As far as I know it would unfortunately need to be in the same drawing. When the option comes to select the line to link with the FIELD, you don't have an option of exiting the drawing to open another one and you wouldn't be able to open an XREF in place to do the selecting either. Quote
fcfcadd Posted September 1, 2010 Author Posted September 1, 2010 Ok. Im giving that a try right now to see if that works. I don't mind it if the bom is in the same drawing as the lines them selves. As long as it updates with the line change. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.