Jump to content

Recommended Posts

Posted

Hi

 

I start to use your program Area Label from MAC LEE, but i have some question about it, if could be changed.

It a good program, must say.

I work in civil engeeniring, and i start to use this program for calculating areas of polyline in profiles. Now the resault get in rows, and i tried to get it in colums, but unfortunate. I change the table, but the resault dont suscrabe in colums.

I would like to know it is posible to get the resault in colums (Digging, embankment, gravel, humus,...). That wolud then help easy to calculete the volumes of materials. Additional would be able then to end one profile and to start the other, but then in next row and then attach the resault to table of previous profile. Additional how would be able that would the program read the name of Layer and then sort it in the appropriate colum, that would be earlie defined (Digging, embankment, gravel, humus - the colums of table, and then i would click the polyline of gravel in profile and the program would suscribe the resault in the colum of gravel, and not at the start of the first colum). That would be usefull, because some profiles don't have the same materials.

Now if its a easy project (not alot profiles), i do the profiles with Civil, because its got that the profiles are dinamic if it is changes something, that suscribe it and calculete, but it take alot time to do a good surface. We have some other program for profiles but are not dinamic, we have to draw the materias alone, and if we change the area, than we have manual change the resault (excel) and calculete it,...

Now if it could be everything done in AC, than we could take the tabel out an insert it into excel or we could do AF (to file) and then repair it in excel,...

 

Something like this (we have to add the volumes of material with the profiles).

Prikaz1.jpg

Prikaz.xls

Posted

LEE MAC i wrotw this here becauce i couldn't do the conect on your page (its a good page, usefull)

Posted

I'm glad you could find my program useful, however I am not looking to modify this program to the extent that you describe to suit the needs of one individual.

Posted

Just thinking out load :o ... would it be possible for you to use Excel's VLookup/HLoopkup function to achieve what you wanted? I.e. the "table" generated from Lee's code you simply use as a form of "database" then your resulting table uses one or more of the lookup formulas of Excel to extract the relevant data items from the table generated by Lee's code.

 

It's how I used to do it from the table generated through Data Extract. I left that file as is, so I could simply overwrite it whenever I needed to update the areas. Then all that needed was to open my calculated Excel file and the updates would be extracted automatically.

Posted

Irneb thanx, i will try this to do something with this,....

Now its more problem, because i also need the name of the polyline, cause i have all polylines on named layers. Now i do AF an than can be this numbers copied to excel, but it isnt dinamic. now i must modified LEE's code that this table would suscribe the nam of layer and area of polyline but i'm tryng but i'm not programmer like LEE :) and than try with excel.

First i did this with eattext, but we have to do all of the profiles on hyperlink and then edit it in excel. (but i would like dinamic)

Posted

I don't know about "dynamic" ... perhaps you should look into the Data Extraction rather (where you can specify which properties of what type of entity on which layer, etc. etc. etc. and then have it placed in various columns into an XLS file). But I'm not sure exactly what you're after.

Posted

I will rather use eattext and than export to excel.

(defun C:FA  (/ acsp adoc cpt elist en ent fld lead_obj lpt mtx oid osm)
 (vl-load-com)
 (or adoc
     (setq adoc
        (vla-get-activedocument
          (vlax-get-acad-object)
          )
       )
     )
 (if (and
   (= (getvar "tilemode") 0)
   (= (getvar "cvport") 1)
   )
   (setq acsp (vla-get-paperspace adoc))
   (setq acsp (vla-get-modelspace adoc))
   )
(setq osm (getvar "osmode"))
 (setvar "osmode" 0)

 (while
   (setq ent (entsel "\nSelect pline or hit Enter to exit"))
    (setq en (car ent))
    (if (wcmatch (cdr (assoc 0 (setq elist (entget en)))) "*POLYLINE")
      (progn
    (setq cpt (trans (cadr ent)1 0)
          lpt (trans (getpoint cpt "\nPick the ending point of leader:") 1 0)
          )

    (setq oID (vla-get-objectid (vlax-ename->vla-object en)))
    (setq fld
       (strcat
         (strcat "%<\\AcObjProp Object(%<\\_ObjId "
             (itoa oID)
             ">%).Layer \\f \"%lu2%pr2\">%" " = " "%<\\AcObjProp Object(%<\\_ObjId "
             (itoa oID)
             ">%).Area \\f \"%lu2%pr2\">%" " M2 "
             ))  
          )
    (setq mtx (vlax-invoke
            acsp 'AddMText lpt 0.0 fld)
          )
    (vlax-put mtx
          'AttachmentPoint
          (cond ((> (car cpt) (car lpt))
             6
             )
            ((< (car cpt) (car lpt))
             4
             )
            (T 4)
            )
          )
    (vlax-put mtx 'Height (getvar "textsize"))
    )
      )
    )
 (setvar "osmode" osm)
 (princ)
 )
(princ "\n Start command with FA ...")
(princ)

or will do the table and than use

(defun C:AREATT ( / en obj tblobj row col lst pt rows cols what fld)
;;;; Command: AREATT (AREA to table)
;;;; Posted http://dwg.ru/f/showthread.php?t=14528
;;;; This command allows you to insert into the specified table cell and the subsequent
;;;; Text field (FIELD), containing the value of the square of the selected object.
;;;; Depending on the choice of navigation options by rows or columns.
;;;; If rows or columns coming to an end, they are automatically added.
;;;; Formatting cell is taken as specified in the first cell.
;;;; Precision of rounding and scaling factor are given the option "Setting"
;;;; Since this field is associated with a particular object, if you change 
;;;; Object field is recalculated (need updating field) 
;;;; Code can be stored in a file areatt.lsp 
;;;; Possible macro to a button or menu item: 
;;;; ^ C ^ C (if (not C: AREATT) (load "AREATT")); AREATT;  
 (vl-load-com)
 (or *SCALE* (setq *SCALE* 1))
 (or *PREC* (setq *PREC* 2))
 (or *TEXTSIZE* (setq *TEXTSIZE* (getvar "TEXTSIZE")))
 (or *SUFF* (setq *SUFF* ""))(or *PREF* (setq *PREF* ""))
 (setq *SUFF* (vl-princ-to-string *SUFF*))
 (setq *PREF* (vl-princ-to-string *PREF*))
 (princ "\nCurrent scale = ")(princ *SCALE*)
 (princ " Current precision = ")(princ *PREC*)
 (princ " Text size = ")(princ *TEXTSIZE*)
 (princ " Prefix= ")(princ *PREF*)(princ " Suffix= ")(princ *SUFF*)
 (setq  tblobj nil tblobj (ssget "_X" '((0 . "ACAD_TABLE"))))
 (setq lst (mapcar 'vlax-ename->vla-object(vl-remove-if 'listp (mapcar 'cadr (ssnamex tblobj)))))
 (setq  tblobj nil)
 (cond
  ((and lst
        (or (initget "Row Col Setting _Row Col Setting") t)
        (or (while (=(setq what (getkword "\nNavigate [on tne Row/on the Columns/Setting] <on the Columns>: "))
                     "Setting")
                    (princ "\nNew scale <")(princ *SCALE*)(princ "> : ")
     (initget 6)
     (if (setq en (getdist))(setq *SCALE* en))
     (princ "\nNew  precision <")(princ *PREC*)(princ "> : ")
     (initget 4)
     (if (setq en (getint))(setq *PREC* en))
     (princ "\nNew text size <")(princ *TEXTSIZE*)(princ "> : ")
     (initget 6)
     (if (setq en (getdist))(setq *TEXTSIZE* en))
     (princ "\nPrefix (space - clear) <")(princ *PREF*)(princ "> : ")
     (if (= (setq en (getstring t)) " ")(setq en ""))
     (if (= (substr (vl-string-left-trim "\/" en) 1 2) "U+")
     (setq en (strcat "\\" (vl-string-left-trim "\/" en))))(setq *PREF* en)
     (princ "\nSuffix? (space - clear) <")(princ *SUFF*)(princ "> : ")
     (if (= (setq en (getstring t)) " ")(setq en ""))
     (if (= (substr (vl-string-left-trim "\/" en) 1 2) "U+")
     (setq en (strcat "\\" (vl-string-left-trim "\/" en))))(setq *SUFF* en)
              (initget "Row Col Setting _Row Col Setting")
              )
            t
            )
        (or what (setq what "Col"))
        (or
       (while (null  tblobj)
         (initget 1)
         (setq pt (getpoint "\nSpecify a first table cell:"))
         (mapcar '(lambda (x)
          (or tblobj
              (and
                (= :vlax-true (vla-HitTest x
                              (vlax-3d-point (trans pt 1 0))
                              (vlax-3d-point (trans (getvar "VIEWDIR") 1 0))
                              'row 'col))
                (setq tblobj x)
                )
              )
          )
       lst)
         (if (null  tblobj)(princ " ** missing **"))
         )
       t)
        (or
          (vlax-write-enabled-p tblobj)
          (and
            (princ "\nTable on a locked layer!")
            nil
            )
          )
        (setq pt (vla-GetCellAlignment tblobj row col))
        )
   (setq rows (vla-get-rows tblobj))
   (setq cols (vla-get-columns tblobj))
   (while (setq en (car (entsel "\nSelect the entity to insert it square into the table (ENTER - exit): " )))
     (cond
      ((vlax-property-available-p (setq en (vlax-ename->vla-object en)) 'Area)
         (setq fld (strcat "%<\\AcObjProp Object(%<\\_ObjId "
            (vl-princ-to-string(Get-ObjectID-x86-x64 en))
               ">%).Area \\f \"%lu2%ps["*PREF* "," *SUFF*
               "]%pr"(itoa *PREC*) "%ct8["(vl-princ-to-string *SCALE*)"]\">%"
               ) ;_ strcat
         )
       (cond
         ((= col cols)
           (vla-insertColumns tblobj col (vla-GetColumnWidth tblobj (1- col)) 1)
           (vla-SetCellAlignment tblobj row col pt)
           (setq rows (vla-get-rows tblobj))
           (setq cols (vla-get-columns tblobj))
           
         )
         ((= row rows)
           (vla-insertRows tblobj row (vla-GetRowHeight tblobj (1- row)) 1)
          (vla-SetCellAlignment tblobj row col pt)
           (setq rows (vla-get-rows tblobj))
           (setq cols (vla-get-columns tblobj))
        )
         (t nil))
       (vla-SetText tblobj row col fld)
       (if (= what "Col")(setq col (1+ col))(setq row (1+ row)))
       
      )
      (t(princ "\nThis primitive can not get property Area!"))
     )
     
   )
  )
  (t
    (princ "\nTables not found!")
  )
 )
 (princ)
)
;;------------------------------------------------ --------
;; Function gets a string representation ObjectID
;; Whether AutoCAD x86 or x64
;; Source: https: / / discussion.autodesk.com / forums / message.jspa? MessageID = 6172961
;; Http://forum.dwg.ru/showthread.php?t=51822
(defun Get-ObjectID-x86-x64 (obj / util)
 (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))))
 (if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj)))
 (if (= (type obj) 'VLA-OBJECT)
    (if (> (vl-string-search "x64" (getvar "platform")) 0)
      (vlax-invoke-method util "GetObjectIdString" obj :vlax-False)
      (rtos (vla-get-objectid obj) 2 0)
    )
 )
)

I thought it would be possible to have a link that would relate to the content in AutoCAD and when the contents change in AutoCAD would be just this in Excel.

Posted
I thought it would be possible to have a link that would relate to the content in AutoCAD and when the contents change in AutoCAD would be just this in Excel.
The closest to that is Data Extraction. What you're after sounds like you want an ODBC driver for DWG files. That would ne nice yes, then the Excel file could directly link to anything inside the DWG through an SQL query. But unfortunately there's no such thing - ADesk's only provided the Data Extract in the other direction (i.e. from within ACad exporting to Excel).

 

You could of course make a lisp which updates the Excel file through a single click on a button. This comes close to what Lee's code does. But then if you want it customized to your particular needs then you have to modify it yourself, or find some guy who has enough time on hand. If you want a change reflected in the XLS as and when it happens in the DWG, it is possible through adding reactors to the lisp. Though I'd advise against this as it would make your ACad slow beyond measure!

Posted

Thank you. I will use the Data Extraction, as the occasion to use, but if it will change the surface profiles, will be those couple of data in Excel introduced manually.

I thought something like this already exists, because I assumed that it is used a lot of people, or the sprogramiralo to have a dynamic plain AutoCAD Civil 3D as profiles, but that they would not have changed in AutoCAD but as an area in Excel, because I assumed that this would be easier to do some kind of link Excel to AutoCAD that this would only change if the changed data in AutoCAD.

Posted
But then if you want it customized to your particular needs then you have to modify it yourself

 

I'm not P of programmer :),

I only use AutoCAD, but I would like certain things that are repetitive and routine processed in a simple way to make things running quickly, efficiently and with less chance of error

Posted

That's usually the reason people become programmers. They're tired of doing the same commands over and over again, they start thinking: "This can be done a lot more easily, can't it?". Then start looking at macros, find that you can only go so far. Then look at VBA/Lisp (though these days VBA is a bit hampered, especially on 64bit) and find that you can do most anything. It's only in some cases where they tend to go even further.

Posted

I agree,...

Now i have other problem, tables in AC cant be join and then explode to excel as one.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...