polyline attributes and my thesis

Discussion in 'AutoCAD' started by polaros, Jun 13, 2004.

  1. polaros

    polaros Guest

    Hello
    I need some help with my thesis.
    I am making program which in generally will get some data from Autocad to Acess and make some calculations.
    It will be helpful to younger students on their small factory project during the II Lear. I would like to know how can I make polyline with attributes. When user draws polyline he needs to define 2 nodes an length of that line ( it’s important to calculate diameter of electrical cable, current etc.) and that data will be connected to that polyline ( like attributes in block) so I can send them to Acces. I read that it is possible to make it which XData, I read something about it but it's too difficult for me. I am a newbie in Autolisp so I will be very thankful for help. Maciek
     
    polaros, Jun 13, 2004
    #1
  2. polaros

    ECCAD Guest

    I suggest you insert a 'block' with hidden attributes. Create a 'polyline' lisp program that allows pick of the (2) node points, draws a 'polyline' between, and on Point1, insert the block with the attributes. (setvar "attdia" 1), so they enter data. You could then easliy search for the 'block', pull the attributes and export them to Access. I wouldn't go the route of Xdata - just complicates the process (in my opinion).

    Bob
     
    ECCAD, Jun 13, 2004
    #2
  3. Hi,

    If you choose to go the route of VBA instead of lisp there is sample code in
    the help files to do about 90% of the work. In addition there is a sample
    program for linking to lisp.

    There may be sample code for Lisp, but I have not looked for it.


    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au

    Acess and make some calculations.
    during the II Lear. I would like to know how can I make polyline with
    attributes. When user draws polyline he needs to define 2 nodes an length of
    that line ( it's important to calculate diameter of electrical cable,
    current etc.) and that data will be connected to that polyline ( like
    attributes in block) so I can send them to Acces. I read that it is possible
    to make it which XData, I read something about it but it's too difficult for
    me. I am a newbie in Autolisp so I will be very thankful for help. Maciek
     
    Laurie Comerford, Jun 13, 2004
    #3
  4. ;Here are some of the subroutines I use to accomplish this -

    ;This the subroutine to register the XData - this must be run prior to
    adding or retrieving XData
    ;--register extended data for partnumber--------------------------
    (defun XDregappNUM (/ XDname)
    (setq XDname "XDnum") ; Set application name
    (if (not (tblsearch "appid" XDname)) ; Checks if already registered
    (if (= (regapp XDname) nil) ; Register and check
    (alert (strcat "\nERROR - \n Can't register XDATA for " XDname
    ". "))
    )
    )
    (princ)
    )

    ;Here are examples of commands to save the data -
    ;1.
    (setq PartNum "1234")
    (setq EG (entget (entlast)))
    (SET_PED EG PartNum)

    ;2.
    (setq PartNum "1234")
    (setq ES (entsel "\nSelect Polyline ? "))
    (if ES
    (progn
    (setq EG (entget (car ES)))
    (SET_PED EG PartNum)
    )
    )

    ;This is the subroutine to add the data to the entity -
    ;--subroutine to save PartNumber Extended Data
    value--------------------------
    (defun SET_PED (EGG P_N / ED)
    (if P_N
    (progn
    (setq ED (list (list -3 (list "XDnum" (cons 1000 P_N)))))
    (setq EGG (append EGG ED))
    (entmod EGG)
    )
    )
    )

    ;Here is an example of commands to get the data -
    (setq ES (entsel "\nSelect Pline to Get Xdata ? "))
    (if (and ES (setq EG (entget (car ES))))
    (progn
    (setq EGE (entget (car ES) (list "XDnum")))
    (GET_PED EGE)
    )
    )

    ;This is the routine to get the XData from a selected entity
    ;--subroutine to get PartNumber Extended Data
    value---------------------------
    (defun GET_PED (EGG /)
    (setq PART_NUM nil)
    (if (assoc -3 EGG)
    (setq PART_NUM (cdr (assoc 1000 (cdadr (assoc -3 EGG)))))
    )
    )

    ;Here is a program to list the XData of an object -
    ;LK = list Entity and XData Text
    (defun C:LK ()
    (setq ES (entsel "\nSelect Entity to List ? "))
    (while ES
    (setq EGS (entget (car ES)))
    (setq EGE (entget (car ES) (list "XDnum")))
    (if (assoc -3 EGE)
    (setq PN (cdr (assoc 1000 (cdadr (assoc -3 EGE)))))
    (setq PN nil)
    )
    (princ (strcat "\nEntity = " (cdr (assoc 0 EGS)) " - XData = "))
    (princ PN)
    (setq ES (entsel "\nSelect Entity to List ? "))
    )
    )


    Good Luck!
    Alan
     
    Alan Henderson @ A'cad Solutions, Jun 14, 2004
    #4
  5. polaros

    polaros Guest

    Thanks I will try it . Once again THX:D
     
    polaros, Jun 15, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.