Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

is there any lisp that can help with this issue?

7 REPLIES 7
Reply
Message 1 of 8
JamaL9722060
920 Views, 7 Replies

is there any lisp that can help with this issue?

Hi all,

 

is there any lisp that can help with my issue below:

 

http://forums.autodesk.com/t5/AutoCAD-2012/How-to-automatically-stick-the-coordinates-obtained-from-...

 

best

 

Jamal

 

---------------------------
Jamal Numan
7 REPLIES 7
Message 2 of 8
Hallex
in reply to: JamaL9722060

Jamal,

What the kind of sort the objects coordinates you want to display??

You can insert fields into table but not for all object types

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 8
JamaL9722060
in reply to: Hallex

Thanks Hallex for the answer.

 

what i need is list the XYZ obtained from the command "list" in a table in the AutoCAD as shown in the screenshot below

 

best

 

Jamal

 

Clip_361.jpg

 

---------------------------
Jamal Numan
Message 4 of 8
stevesfr
in reply to: JamaL9722060
Message 5 of 8
Hallex
in reply to: JamaL9722060

Jamal,

You can try my program from post #9 in there:

http://www.cadtutor.net/forum/showthread.php?15023-coordinates-(-dimensions)-to-excel&highlight=make...

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 6 of 8
Hallex
in reply to: JamaL9722060

In addition try this too:

{code}

(defun C:demo(/ acsp adoc col dimz ip pt row tbl txt x y z)
(setq adoc (vla-get-activedocument (vlax-get-acad-object))
      acsp (vla-get-block (vla-get-activelayout adoc))
)
(setq dimz (getvar "dimzin"))
(setq ip (getpoint "\n Table Location Point: "))


(setvar "dimzin" 0)
(setq tbl (vla-addtable
     acsp
     (vlax-3d-point ip)
     2
     3
     (* (getvar "dimtxt") 2)
     (* (getvar "dimtxt")
        (* (strlen (rtos (car ip) 2 3)) (getvar "dimtxt"))
     )
   )
)
;(vla-put-regeneratetablesuppressed tbl :vlax-true)
(vla-SetText tbl 0 0 "Coordinate Table")
(setq row 1)
(mapcar '(lambda (col txt) (vla-SetText tbl row col txt))
 (list 0 1 2)
 (list "X coord." "Y coord." "Z coord.")
)
(while
  (setq pt (getpoint "\nPick a Point: "))
   (setq x (rtos (car pt) 2 3)
  y (rtos (cadr pt) 2 3)
  z (rtos (caddr pt) 2 3)
   )
   (setq row (1+ row))

   (vla-InsertRowsAndInherit tbl row (- row 1) 1)
   (mapcar '(lambda (col txt) (vla-SetText tbl row col txt)) (list 0 1 2) (list x y z))
)

;(vla-put-regeneratetablesuppressed tbl :vlax-false)
(setvar "dimzin" dimz)

(princ)
  )

{code}

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 7 of 8
JamaL9722060
in reply to: Hallex

Thank you guys for the help.

 

I could extract the coordinates of the points in the light of the help i recieved from Alfred. please, have a look on the link below:

 

http://forums.autodesk.com/t5/AutoCAD-2012/How-to-automatically-stick-the-coordinates-obtained-from-...

 

best

 

Jamal

---------------------------
Jamal Numan
Message 8 of 8

If you want, try this?

 

(vl-load-com)
(defun c:points2cell ( / js AcDoc Space all_path j end_pos id_path fonts_path file_shx
                         nw_style oldim oldlay ins_pt_cell h_t w_c lst_id-seg lst_pt n
                         obj dxf_10 nb nw_obj ename_cell n_row n_column)
  (princ "\nSelect points.")
  (while (null (setq js (ssget '((0 . "POINT")))))
    (princ "\nSelection empty, or is not a point!")
  )
  (setq
    AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
    Space
    (if (= 1 (getvar "CVPORT"))
      (vla-get-PaperSpace AcDoc)
      (vla-get-ModelSpace AcDoc)
    )
  )
  (cond
    ((null (tblsearch "LAYER" "Table-Points"))
      (vla-add (vla-get-layers AcDoc) "Table-Points")
    )
  )
  (cond
    ((null (tblsearch "STYLE" "Text-Cell"))
      (setq all_path (getenv "ACAD") j 0)
      (while (setq end_pos (vl-string-position (ascii ";") all_path))
        (setq id_path (substr all_path 1 end_pos))
        (if (wcmatch (strcase id_path) "*FONTS*")
          (setq fonts_path (strcat id_path "\\"))
        )
        (setq all_path (substr all_path (+ 2 end_pos)))
      )
      (setq file_shx (getfiled "Select a font file " fonts_path "shx" 8))
      (if (not file_shx)
        (setq file_shx "txt.shx")
      )
      (setq nw_style (vla-add (vla-get-textstyles AcDoc) "Text-Cell"))
      (mapcar
        '(lambda (pr val)
          (vlax-put nw_style pr val)
        )
        (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag)
        (list file_shx 0.0 (/ (* 15.0 pi) 180) 1.0 0.0)
      )
      (command "_.ddunits"
        (while (not (zerop (getvar "cmdactive")))
          (command pause)
        )
      )
    )
  )
  (setq
    oldim (getvar "dimzin")
    oldlay (getvar "clayer")
  )
  (setvar "dimzin" 0) (setvar "clayer" "Table-Points")
  (initget 9)
  (setq ins_pt_cell (getpoint "\nLeft-Up insert point of table: "))
  (initget 6)
  (setq h_t (getdist ins_pt_cell (strcat "\nHigth text <" (rtos (getvar "textsize")) ">: ")))
  (if (null h_t) (setq h_t (getvar "textsize")) (setvar "textsize" h_t))
  (initget 7)
  (setq w_c (getdist ins_pt_cell "\nWidth of cells: "))
  (setq
    lst_id-seg '()
    lst_pt '()
    nb 0
  )
  (repeat (setq n (sslength js))
    (setq
      obj (ssname js (setq n (1- n)))
      dxf_10 (cdr (assoc 10 (entget obj)))
      lst_pt (cons dxf_10 lst_pt)
      nb (1+ nb)
      lst_id-seg (cons nb lst_id-seg)
    )
  )
  (mapcar
    '(lambda (p tx)
      (setq nw_obj
        (vla-addMtext Space
          (vlax-3d-point p)
          0.0
          tx
        )
      )
      (mapcar
        '(lambda (pr val)
          (vlax-put nw_obj pr val)
        )
        (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'StyleName 'Layer 'Rotation)
        (list 5 h_t 5 p "Text-Cell" "Table-Points" 0.0)
      )
    )
    lst_pt
    lst_id-seg
  )
  (vla-addTable Space (vlax-3d-point ins_pt_cell) (+ 2 nb) 3 (+ h_t (* h_t 0.25)) w_c)
  (setq ename_cell (vlax-ename->vla-object (entlast)) n_row (1+ nb) n_column -1)
  (vla-SetCellValue ename_cell 0 0
    (vlax-make-variant
      (strcat "Summary of " (itoa (sslength js)) " POINTS")
      8
    )
  )
  (vla-SetCellTextStyle ename_cell 0 0 "Text-Cell")
  (vla-SetCellTextHeight ename_cell 0 0 (vlax-make-variant h_t 5))
  (vla-SetCellAlignment ename_cell 0 0 5)
  (foreach n
    (mapcar'list
      (append lst_id-seg '("N°"))
      (append (mapcar 'rtos (mapcar 'car lst_pt)) '("Coordinates X"))
      (append (mapcar 'rtos (mapcar 'cadr lst_pt)) '("Coordinates Y"))
    )
    (mapcar
      '(lambda (el)
        (vla-SetCellValue ename_cell n_row (setq n_column (1+ n_column))
          (if (or (eq (rtos 0.0) el) (eq (angtos 0.0) el)) (vlax-make-variant "_" 8) (vlax-make-variant el 8))
        )
        (vla-SetCellTextStyle ename_cell n_row n_column "Text-Cell")
        (vla-SetCellTextHeight ename_cell n_row n_column (vlax-make-variant h_t 5))
        (if (eq n_row 1)
          (vla-SetCellAlignment ename_cell n_row n_column 5)
          (vla-SetCellAlignment ename_cell n_row n_column 6)
        )
      )
      n
    )
    (setq n_row (1- n_row) n_column -1)
  )
  (setvar "dimzin" oldim) (setvar "clayer" oldlay)
  (prin1)
)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost