Author Topic: Mapping Side of a building ?  (Read 1232 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio

  • Guest
Mapping Side of a building ?
« on: February 26, 2017, 04:01:43 AM »
Hi i measure the side of a building but i have problem with the point view. I see the points from thw top. If i change the view i can not see the code of the points so i can't draw them. I am searching for a lisp to rotate and lift the points. Any ideas ?

pedroantonio

  • Guest
Re: Mapping Side of a building ?
« Reply #1 on: February 26, 2017, 10:08:45 AM »
How to write the command rotate  referense and then point ?

Code - Auto/Visual Lisp: [Select]
  1. (command "ROTATE" ssget "" "_R" "_P")
  2.  

pedroantonio

  • Guest
Re: Mapping Side of a building ?
« Reply #2 on: February 26, 2017, 10:44:02 AM »
I fix the problem how to export the points but i need help with the rotation

I think something like this

1)selecti all point
2)select the first line for the angle or pick 2 points to give the angle
3)select the align line to rotate

Any ideas?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / *error* del des ent idx lst obj ord out rtn sel )
  2.  
  3.     (defun *error* ( msg )
  4.         (if (= 'file (type des))
  5.             (close des)
  6.         )
  7.         (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
  8.             (princ (strcat "\nError: " msg))
  9.         )
  10.         (princ)
  11.     )
  12.  
  13.     (setq ord '("POINT" POINT-X "ELEV")
  14.           out  (LM:uniquefilename (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname))) ".ops")
  15.           del  ","
  16.     )
  17.     (if (setq sel (ssget '((0 . "INSERT") (66 . 1))))
  18.         (if (setq des (open out "w"))
  19.             (progn
  20.                 (repeat (setq idx (sslength sel))
  21.                     (setq ent (ssname sel (setq idx (1- idx)))
  22.                           obj (vlax-ename->vla-object ent)
  23.                     )
  24.                     (setq lst
  25.                         (append
  26.                             (mapcar '(lambda ( a b ) (cons a (rtos b)))
  27.                                '(point-x point-y point-z)
  28.                                 (trans (cdr (assoc 10 (entget ent))) ent 0)
  29.                             )
  30.                             (mapcar '(lambda ( x ) (cons (strcase (vla-get-tagstring x)) (vla-get-textstring x)))
  31.                                 (append
  32.                                     (vlax-invoke obj 'getattributes)
  33.                                     (vlax-invoke obj 'getconstantattributes)
  34.                                 )
  35.                             )
  36.                         )
  37.                     )
  38.                   (setq rtn (cons (vl-remove 'nil (mapcar '(lambda ( x ) (cdr (assoc x lst))) ord)) rtn))
  39.                 )
  40.       (foreach idx (LM:alphanumsort-i (mapcar 'car rtn))
  41.       (write-line (LM:lst->str (nth idx rtn) del) des)
  42.    )
  43.                 (setq des (close des))
  44.             )
  45.             (princ (strcat "\nUnable to open file: \"" out "\" for writing."))
  46.         )
  47.     )
  48.     (princ)
  49. )                
  50.  
  51. ;; List to String  -  Lee Mac
  52. ;; Concatenates each string in a list, separated by a given delimiter
  53.  
  54. (defun LM:lst->str ( lst del )
  55.     (if (cdr lst)
  56.         (strcat (car lst) del (LM:lst->str (cdr lst) del))
  57.         (car lst)
  58.     )
  59. )
  60.  
  61. ;; Unique Filename  -  Lee Mac
  62. ;; Returns a unique filename for a given path & file extension
  63.  
  64. (defun LM:uniquefilename ( pth ext / fnm tmp )
  65.     (if (findfile (setq fnm (strcat pth ext)))
  66.         (progn
  67.             (setq tmp 1)
  68.             (while (findfile (setq fnm (strcat pth "(" (itoa (setq tmp (1+ tmp))) ")" ext))))
  69.         )
  70.     )
  71.     fnm
  72. )
  73.  
  74. ;; Alphanumerical Sort-i  -  Lee Mac
  75. ;; Sorts a list of strings containing a combination of alphabetical & numerical characters and returns the indices.
  76.  
  77. (defun LM:alphanumsort-i ( lst )
  78.     (vl-sort-i (mapcar 'LM:splitstring lst)
  79.         (function
  80.             (lambda ( a b / x y )
  81.                 (while
  82.                     (and
  83.                         (setq x (car a))
  84.                         (setq y (car b))
  85.                         (= x y)
  86.                     )
  87.                     (setq a (cdr a)
  88.                           b (cdr b)
  89.                     )
  90.                 )
  91.                 (cond
  92.                     (   (null x) b)
  93.                     (   (null y) nil)
  94.                     (   (and (numberp x) (numberp y)) (< x y))
  95.                     (   (numberp x))
  96.                     (   (numberp y) nil)
  97.                     (   (< x y))
  98.                 )
  99.             )
  100.         )
  101.     )
  102. )
  103.  
  104. ;; Split String  -  Lee Mac
  105. ;; Splits a string into a list of text and numbers
  106.  
  107. (defun LM:splitstring ( str )
  108.     (
  109.         (lambda ( l )
  110.             (read
  111.                 (strcat "("
  112.                     (vl-list->string
  113.                         (apply 'append
  114.                             (mapcar
  115.                                 (function
  116.                                     (lambda ( a b c )
  117.                                         (cond
  118.                                             (   (or (= 34 b) (= 92 b))
  119.                                                 (list 32 34 92 b 34 32)
  120.                                             )
  121.                                             (   (or (< 47 b 58)
  122.                                                    ;(and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
  123.                                                     (and (= 46 b) (< 47 a 58) (< 47 c 58))
  124.                                                 )
  125.                                                 (list b)
  126.                                             )
  127.                                             (   (list 32 34 b 34 32))
  128.                                         )
  129.                                     )
  130.                                 )
  131.                                 (cons nil l) l (append (cdr l) '(( )))
  132.                             )
  133.                         )
  134.                     )
  135.                     ")"
  136.                 )
  137.             )
  138.         )
  139.         (vl-string->list str)
  140.     )
  141. )
  142.  
  143.  
  144.  
  145.  
  146.  

Pad

  • Bull Frog
  • Posts: 342
Re: Mapping Side of a building ?
« Reply #3 on: February 28, 2017, 05:02:03 AM »
A bit long winded, but given your drawing has the points in 3d and the blocks in 2d, a few extra steps are required.

Here are the steps that I got to work:

1.  Elevate the blocks by the level attribute value
 lisp Attools | Cal | Delta | 0
2. Attsync blocks
3. rotate the blocks using your alignment
4. ucs ob pick left hand side of line
5. view cube front
6. UCS view
7. Copy paste into new drawing, to get the ucs as wcs for the next step.
8. Rotate blocks so that they are readable
Lisp reverttoblocks

See attached files and elev.dwg

This lisp would save copying and pasting into a new drawing if it could be modified to work with multiple blocks using their individual insertion points
.
Code - Auto/Visual Lisp: [Select]
  1. ;;;;http://www.cadtutor.net/forum/archive/index.php/t-84738.html?s=4e68c2e84bd785f978a37c43d09042a7
  2.  
  3. (defun c:3dbr ( / ang axs bpt ent obj )
  4.     (while
  5.         (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect block to rotate: ")))
  6.             (cond
  7.                 (   (= 7 (getvar 'errno))
  8.                     (princ "\nMissed, try again.")
  9.                 )
  10.                 (   (/= 'ename (type ent)) nil)
  11.                 (   (/= "INSERT" (cdr (assoc 0 (entget ent))))
  12.                     (princ "\nPlease select a block.")
  13.                 )
  14.                 (   (setq obj (vlax-ename->vla-object ent)
  15.                           bpt (vlax-get obj 'insertionpoint)
  16.                           ang (/ pi 2.0)
  17.                     )
  18.                     (princ "\nRotate about [X/Y/Z] <Exit>: ")
  19.                     (while
  20.                         (setq axs
  21.                             (cdr
  22.                                 (assoc (grread nil 10)
  23.                                    '(
  24.                                         ((2 120) 1.0 0.0 0.0)
  25.                                         ((2 088) 1.0 0.0 0.0)
  26.                                         ((2 121) 0.0 1.0 0.0)
  27.                                         ((2 089) 0.0 1.0 0.0)
  28.                                         ((2 122) 0.0 0.0 1.0)
  29.                                         ((2 090) 0.0 0.0 1.0)
  30.                                     )
  31.                                 )
  32.                             )
  33.                         )
  34.                         (vlax-invoke obj 'rotate3d bpt (mapcar '+ bpt axs) ang)
  35.                     )
  36.                 )
  37.             )
  38.         )
  39.     )
  40.     (princ)
  41. )


P