Jump to content

Little complicated lisp...assign Z coord to a point


goldy2000

Recommended Posts

Hello there!!!

 

Have a question, maybe someone had a deal with it...I have a coordinate with X and Y, no Z (0.00), but have Z in number near that point, I need now to assign that number to that point like this diagram maybe:

 

1. pick number

2. pick point

3. assign number to point

 

I have a lisp that extract Z coord from point to text (so this would be opposite reaction)

 

I have a situation of about 2000 points that don't have Z coordinates but have a number in text format, so it would be complicated to edit every point manually....If anyone have any idea I would be grateful..:geek:

Link to comment
Share on other sites

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

  • eldon

    12

  • goldy2000

    12

  • Lee Mac

    8

  • alanjt

    7

Top Posters In This Topic

Posted Images

Are all the text objects on the same layer?

 

They could be, I found them separated in 3 different layers, but I can put them in one unique layer, did you mean on that or...?

Link to comment
Share on other sites

They could be, I found them separated in 3 different layers, but I can put them in one unique layer, did you mean on that or...?

 

Well, my thinking was this:

 

  • Collect all the points
  • Collect all the Z-text on the layer
  • Foreach each point, get the Z-text that is closest to the point, and put the value in the text as the Z-coord.

This is not bullet-proof, but is the best method I can see, above selecting each text/point manually.

 

Lee

Link to comment
Share on other sites

Well, my thinking was this:

  • Collect all the points
  • Collect all the Z-text on the layer
  • Foreach each point, get the Z-text that is closest to the point, and put the value in the text as the Z-coord.

This is not bullet-proof, but is the best method I can see, above selecting each text/point manually.

 

Lee

 

Write you in 1 hour Lee...must travel home..

Link to comment
Share on other sites

Try this (when you get home :) )

 

(defun c:putZ (/ dxf txt2num ELST ENT I PT SS TLAY TLST TSS Z)
 (vl-load-com)

 (setq tLay "Text") [color=Red][b];; <<--<  Z-Text Layer[/b][/color]

 (defun dxf (code lst)
   (cdr (assoc code lst)))

 (defun txt2num  (txt)
   (cond ((distof txt 5)) ((distof txt 2)) ((distof txt 1))
         ((distof txt 4)) ((distof txt 3))))
 
 (cond (  (not (tblsearch "LAYER" tlay))

          (princ "\n** Text Layer Non-existent **"))

       (t (if (and (setq i -1 ss (ssget '((0 . "POINT")))) 
                   (setq tss     (ssget "_X" (list (cons 0 "TEXT,MTEXT") (cons 8 tLay)))))
            (progn

              (setq tLst
                (mapcar
                  (function
                    (lambda (x)
                      (cons (dxf 10 x) (dxf 1 x))))
                  (mapcar (function entget)
                    (vl-remove-if (function listp)
                      (mapcar (function cadr) (ssnamex tss))))))
                  
            (while (setq ent (ssname ss (setq i (1+ i))))
              (setq pt (cdr (assoc 10 (setq elst (entget ent)))))

              (setq z
                (cdar
                  (setq tLst
                    (vl-sort tLst
                      (function
                        (lambda (a b)
                          (< (distance (car a) pt) (distance (car b) pt))))))))

              (setq tLst (cdr tLst))
              (or (setq z (txt2num z)) (setq z 0.0))
              
              (entmod (subst (cons 10 (list (car pt) (cadr pt) z)) (assoc 10 elst) elst)))))))

 (princ))

                        

Link to comment
Share on other sites

G'morning.....Thx Lee for lisp, I tried it but don't understand it quite...I make TEXT layer, and first highlight point(s) and then what..? I tried to select Z txt but nothing happened

Link to comment
Share on other sites

Having looked at the file, I would say that a completely automatic lisp would be impossible in places, due to the relative placement of the elevation text in relation to the ground point.

 

For example, the text is not at a consistent displacement left or right. In areas of congested detail, some levels are on top of other ground points, so a programme to search for the closest text would choose the wrong one. In some areas there is no elevation text for a ground point. Some of the ground points are blocks.

 

All in all, I would go for a manual approach.. I hesitate to post my lisp to do this, because last time, I was chided for producing an untidy lisp. All I know is that it works, and for 2000 points, you could do that in an hour or so. With Osnaps set to suitable settings, the work goes quite fast, even if it is one at a time.

Link to comment
Share on other sites

Having looked at the file, I would say that a completely automatic lisp would be impossible in places, due to the relative placement of the elevation text in relation to the ground point.

 

For example, the text is not at a consistent displacement left or right. In areas of congested detail, some levels are on top of other ground points, so a programme to search for the closest text would choose the wrong one. In some areas there is no elevation text for a ground point. Some of the ground points are blocks.

 

All in all, I would go for a manual approach.. I hesitate to post my lisp to do this, because last time, I was chided for producing an untidy lisp. All I know is that it works, and for 2000 points, you could do that in an hour or so. With Osnaps set to suitable settings, the work goes quite fast, even if it is one at a time.

 

Thx for your time Eldon, manual approach lisp would also be good in this case, maybe much more better solution than automatic lisp8)

Link to comment
Share on other sites

The lisp is not complicated, and as long as Lee Mac is not looking, here it is

 

(defun c:grlev ( / p1 tx e zd os); puts 3D point at level shown by text; by eldon 2000
   (setvar "OSMODE" 104); set Osnap for picking plan point    
   (setq p1 (getpoint "\n Pick plan point.....   "))
       (setvar "OSMODE" 64)
       (setq tx (entsel "\n Pick Level text......   "))
   (setvar "OSMODE" 0)
       (setq e (entget (car tx)))
   (setq zd (atof (cdr (assoc 1 e))))
   (setq p1 (list (car p1) (cadr p1) zd))
   (command "point" p1)
)

You have to set up the Osmode variable according to the list below. It is currently set for Node, Insertion and Intersection. It works one point at a time, but by pressing the right mouse button, it starts again. There are no error traps. I hope it works for you.

 

 

Sets running Object Snap modes using the following bitcodes:

 

0 NONe

1 ENDpoint

2 MIDpoint

4 CENter

8 NODe

16 QUAdrant

32 INTersection

64 INSertion

128 PERpendicular

256 TANgent

512 NEArest

1024 QUIck

2048 APParent Intersection

4096 EXTension

8192 PARallel

 

To specify more than one object snap, enter the sum of their values. For example, entering 3 specifies the Endpoint (bitcode 1) and Midpoint (bitcode 2) object snaps. Entering 16383 specifies all object snaps.

Link to comment
Share on other sites

:shock:YEP, that is it, I found that it makes new points with correct Z coord, after I do this just quick select all Z=0 and erase and this is it!!!!! Thx man, you helped me a lot!!!8)

Link to comment
Share on other sites

Very glad to help.

 

Perhaps you can work out what is happening in the lisp, and then start writing your own. That is how I started 15 years ago, before there was CADTutor :shock:

Link to comment
Share on other sites

Very glad to help.

 

Perhaps you can work out what is happening in the lisp, and then start writing your own. That is how I started 15 years ago, before there was CADTutor :shock:

 

I wanted to do it already, but always find something to do for my work, but think I should do it once:glare:, it seems not so complicated?? To examine some tutorials and think this would be a good start..o:)

Link to comment
Share on other sites

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...