Jump to content

Recommended Posts

Posted

Hi, wondering if any of you clever people can help. I've browsed the various lisps on here for labelling the Z value of a point, but none of them quite do what I want...

 

I have a 3D polyline and I want to add a label at each vertex comprising a level cross (ideally using my existing cross block) with a piece of text centred above this giving the Z value. The complication is that I want my cross and its label to be 2D (ie. to have a Z value of 0) once it's been inserted.

 

Anyone feeling like a small challenge?? Thanks in advance, and obviously let me know if I've not explained myself well enough or you have other questions...

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • Rooster

    11

  • David Bethel

    7

  • Lee Mac

    1

  • tombu

    1

Top Posters In This Topic

Posted Images

Posted

Can you post a sample ?

Posted

Screenshot of what I'm trying to label (the yellow line).

3DP_to Label.jpg

Posted
I've browsed the various lisps on here for labelling the Z value of a point, but none of them quite do what I want...

 

I have a 3D polyline and I want to add a label at each vertex comprising a level cross (ideally using my existing cross block) with a piece of text centred above this giving the Z value. The complication is that I want my cross and its label to be 2D (ie. to have a Z value of 0) once it's been inserted.

 

Can you attach a drawing with a 3D polyline labeled with the existing cross block you want to use?

Posted

Thanks for your interest, Tombu.

 

DWG file attached with the 3D polyline, level cross block and accompanying text for experimentation!

3Dpl_ZLabel.dwg

Posted

While I don't quite understand all of the details, this should get you started :

[b][color=BLACK]([/color][/b]defun c:zlabel [b][color=FUCHSIA]([/color][/b]/ ss i en ed vn vd vl txt z[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not ss[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"POLYLINE"[/color][b][color=BLUE])[/color][/b]
                              [b][color=BLUE]([/color][/b]cons -4 [color=#2f4f4f]"="[/color][b][color=BLUE])[/color][/b]
                                [b][color=BLUE]([/color][/b]cons 70 8[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq i 0[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]setq en [b][color=MAROON]([/color][/b]ssname ss i[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ed [b][color=MAROON]([/color][/b]entget en[b][color=MAROON])[/color][/b]
              vn [b][color=MAROON]([/color][/b]entnext en[b][color=MAROON])[/color][/b]
              vd [b][color=MAROON]([/color][/b]entget vn[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]= [color=#2f4f4f]"VERTEX"[/color] [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 0 vd[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
               [b][color=MAROON]([/color][/b]setq vl [b][color=GREEN]([/color][/b]cons [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 10 vd[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] vl[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
               [b][color=MAROON]([/color][/b]setq vn [b][color=GREEN]([/color][/b]entnext vn[b][color=GREEN])[/color][/b]
                     vd [b][color=GREEN]([/color][/b]entget vn[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq i [b][color=MAROON]([/color][/b]1+ i[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]setq txt 0.075[b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]foreach v vl
   [b][color=NAVY]([/color][/b]setq z [b][color=MAROON]([/color][/b]caddr v[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]

   [b][color=NAVY]([/color][/b]entmake [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 0 [color=#2f4f4f]"INSERT"[/color][b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 2 [color=#2f4f4f]"LEV-50A"[/color][b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 8 [color=#2f4f4f]"LEVELS"[/color][b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 10 v[b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]list 210 0 0 1[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]

   [b][color=NAVY]([/color][/b]entmake [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 0 [color=#2f4f4f]"TEXT"[/color][b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 1 [b][color=BLUE]([/color][/b]rtos z 2 4[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 6 [color=#2f4f4f]"BYLAYER"[/color][b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 7 [color=#2f4f4f]"STANDARD"[/color][b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 8 [color=#2f4f4f]"LEVELS"[/color][b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 10 [b][color=BLUE]([/color][/b]polar v [b][color=RED]([/color][/b]* pi 0.5[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]* txt 2[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 11 [b][color=BLUE]([/color][/b]polar v [b][color=RED]([/color][/b]* pi 0.5[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]* txt 2[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 39 0[b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 40 txt[b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 41 1[b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 50 0[b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 51 0[b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 62 256[b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 71 0[b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 72 4[b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]cons 73 0[b][color=GREEN])[/color][/b]
                  [b][color=GREEN]([/color][/b]list 210 0 0 1[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

-David

Posted

Thanks David - a good start, and I really appreciate the time you've obviously spent on this!

 

Couple of comments: [1] I would like to keep the values to 2 decimal places; [2] I also need the text and block to to have no Z value themselves after insertion (ie. to do this manually I would need to use the FLATTEN command). While I realise they initially need to use the same Z of the vertex they relate to, is it possible once the text contains the value of the polyline to then flatten them automatically?

Posted

Some hints :

 

RealToString Conversions

 

(rtos number 2 2)

See the sysvars lunits and luprec

 

Set the sysvar "DIMZIN" to 0

 

 

 

Polar calculation of points

(polar (list (car v) (cadr v) 0) .....

Forces the Z axis to 0

 

-David

Posted

Thanks David - I'll play with those settings and see where I get

Posted

David, with your help I've changed the 2dec places setting. However, I'm afraid my lisp knowledge is not good enough to really know what to do with forcing the text & block onto a Z of 0. I've done a bit of trial and error trying to add in your line of code, but not having any success...

Posted

At least you tried.

 

Change :

(cons 11 (polar v (* pi 0.5) (* txt 2)))

 

To:

 

(cons 11 (polar (list (car v) (cadr v) 0) (* pi 0.5) (* txt 2)))

 

Do this also for the (cons 10 (polar v .....) statement as well

 

-David

Posted (edited)

Thank you so much... and yes, I did try! I've also realised that I need to do something similar to force the block to Z of 0 too. Going on what you changed above, I was hoping that all I needed to do to accomplish this was to change the line:

 

(cons 10 v)

 

to

 

(cons 10 (polar (list (car v) (cadr v) 0)))

 

but that hasn't done it. Am I close?

Edited by Rooster
typo
Posted

No need for polar in that case, just:

(list 10 (car v) (cadr v) 0.0)

Posted

Thank you Lee. So glad you chaps are about to help out. One last question: if I want to play with the positioning of the text, does one of your lines above control this?

Posted

Text display can be a fairly complex subject

 

DXF groups 10, 11, 50, 72, 73 & 210 control the entity points, rotation and justifications

 

The STYLE table controls the font and it's properties

 

I used (cons 72 4) to force the text to middle justification. Group 11 then specifies the middle point.

 

 

-David

Posted

Thanks David. I did find and had a play with the settings for groups 72 & 73, which will probably get me what I need. I think I was hoping I could play with the text position/offset distance from the block, but that's just a minor thing.

 

Zac - thanks for the pointer. I did come across that lisp when I was first searching for help. While it's not exactly what I was looking for, it's certainly a useful alternative (some other useful lisps available there too).

Posted
Thanks David. I did find and had a play with the settings for groups 72 & 73, which will probably get me what I need. I think I was hoping I could play with the text position/offset distance from the block, but that's just a minor thing.

 

I set a variable for the txt height

(setq txt 0.075)

 

I simply made text location @90 degrees (* pi 0.5) from the vertex

and

2 times the text height away (* txt 2)

 

Simply edit that statement or change that entire calculation (* txt 2) to a fixed distance

 

-David

Posted
2 times the text height away (* txt 2)

 

Simply edit that statement or change that entire calculation (* txt 2) to a fixed distance

 

-David

 

Perfect - that's the one I was looking for. Very many thanks for all your help on this!

Posted

You're welcome. It sounds like your learned a bit about AutoLisp 8)

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