Rooster Posted April 13, 2016 Share Posted April 13, 2016 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... Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 13, 2016 Share Posted April 13, 2016 Can you post a sample ? Quote Link to comment Share on other sites More sharing options...
Rooster Posted April 13, 2016 Author Share Posted April 13, 2016 Screenshot of what I'm trying to label (the yellow line). Quote Link to comment Share on other sites More sharing options...
tombu Posted April 13, 2016 Share Posted April 13, 2016 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? Quote Link to comment Share on other sites More sharing options...
Rooster Posted April 13, 2016 Author Share Posted April 13, 2016 Thanks for your interest, Tombu. DWG file attached with the 3D polyline, level cross block and accompanying text for experimentation! 3Dpl_ZLabel.dwg Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 13, 2016 Share Posted April 13, 2016 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 Quote Link to comment Share on other sites More sharing options...
Rooster Posted April 13, 2016 Author Share Posted April 13, 2016 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? Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 13, 2016 Share Posted April 13, 2016 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 Quote Link to comment Share on other sites More sharing options...
Rooster Posted April 14, 2016 Author Share Posted April 14, 2016 Thanks David - I'll play with those settings and see where I get Quote Link to comment Share on other sites More sharing options...
Rooster Posted April 14, 2016 Author Share Posted April 14, 2016 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... Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 14, 2016 Share Posted April 14, 2016 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 Quote Link to comment Share on other sites More sharing options...
Rooster Posted April 14, 2016 Author Share Posted April 14, 2016 (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 April 14, 2016 by Rooster typo Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 14, 2016 Share Posted April 14, 2016 No need for polar in that case, just: (list 10 (car v) (cadr v) 0.0) Quote Link to comment Share on other sites More sharing options...
Rooster Posted April 14, 2016 Author Share Posted April 14, 2016 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? Quote Link to comment Share on other sites More sharing options...
Zac Davis Posted April 14, 2016 Share Posted April 14, 2016 Try This one and tell me if its helps Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 14, 2016 Share Posted April 14, 2016 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 Quote Link to comment Share on other sites More sharing options...
Rooster Posted April 14, 2016 Author Share Posted April 14, 2016 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). Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 14, 2016 Share Posted April 14, 2016 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 Quote Link to comment Share on other sites More sharing options...
Rooster Posted April 14, 2016 Author Share Posted April 14, 2016 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! Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 14, 2016 Share Posted April 14, 2016 You're welcome. It sounds like your learned a bit about AutoLisp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.