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

Pline Dimensioning

53 REPLIES 53
Reply
Message 1 of 54
Anonymous
11477 Views, 53 Replies

Pline Dimensioning

Does anyone have a lisp to place aligned dimensions on each segment of a polyline?

I would use it for reinforcing bar detailing.
Thanks for any other suggestion.

Matthew
53 REPLIES 53
Message 21 of 54
Anonymous
in reply to: Kent1Cooper

Hello,

Thanks for the file. I tried this routine on a simple closed orthogonal polyline. It did place the dimensions on the inside but only dimensioned the horizontal segments and instead of lengths, all the dimensions were "_.dimaligned". Do I maybe have something wrong somewhere?

Message 22 of 54
Kent1Cooper
in reply to: Kent1Cooper


Kent1Cooper wrote:

....

Attached is my approach, DimPolyInside.lsp with its DPI command....


Then I thought about it a little and decided to make a combined file [attached DimPoly.lsp] that defines both DPI [for Inside] and DPO [for Outside] commands.  So if, in something that doesn't have a clear inside and outside, the command you try doesn't put the dimensions on the side you want, you can just undo it and use the other command, rather than needing to reverse the Polyline.

Kent Cooper, AIA
Message 23 of 54
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

Hello,

Thanks for the file. I tried this routine on a simple closed orthogonal polyline. It did place the dimensions on the inside but only dimensioned the horizontal segments and instead of lengths, all the dimensions were "_.dimaligned". Do I maybe have something wrong somewhere?


Very odd -- it was working in my testing situation as I wrote it.  Seeing your message, I got into another drawing, and it worked on some, but not all, Polylines, and where it didn't work, it wasn't the same problem you got.  Then I just rotated one that it hadn't worked on, and it did work on it in the changed orientation.  If I can figure out the issue, I'll be back....

Kent Cooper, AIA
Message 24 of 54
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
Very odd -- it was working in my testing situation as I wrote it.  Seeing your message, I got into another drawing, and it worked on some, but not all, Polylines, and where it didn't work, it wasn't the same problem you got.  Then I just rotated one that it hadn't worked on, and it did work on it in the changed orientation.  If I can figure out the issue, I'll be back....

I figured out what was causing my error:

 

....

    (setq
      pt1 (vlax-curve-getPointAtParam pl inc)
      pt2 (vlax-curve-getPointAtParam pl (- inc 0.5)); segment midpoint
      pt3 (vlax-curve-getPointAtParam pl (1- inc))
;| originally had:
    ); setq
    (if (equal (angle pt1 pt2) (angle pt2 pt3) 1e-8); line segment
  But on segment running in zero-degree direction, can sometimes get something like:
  (angle pt1 pt2) = 0.0
  (angle pt2 pt3) = 6.28319
  but the latter is not EXACTLY (* pi 2) -- difference shows up at 15th decimal place!
  So:
|;
      ang1 (angle pt1 pt2)
      ang2 (angle pt2 pt3)
    ); setq
    (if
      (or ; line segment
        (equal ang1 ang2 1e-8); any non-0 direction or both reading as 0
        (and (equal ang1 0 1e-8) (equal ang2 (* pi 2) 1e-8)); condition described above
        (and (equal ang1 (* pi 2) 1e-8) (equal ang2 0 1e-8)); opposite relationship
      ); or
      (command "_.dimaligned" ....

 

That substitution fixed my problem, though I admit I doubt it will fix yours.  I'll keep trying to think of what your trouble could be.

Kent Cooper, AIA
Message 25 of 54
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
....

That substitution fixed my problem, though I admit I doubt it will fix yours.  I'll keep trying to think of what your trouble could be.


When I thought about it some more, I wondered whether it might fix your problem.  Yours is causing a text override on what should be linear Dimensions,  But the only thing in the routine that would cause a text override should be if it's doing an arc-segment Dimension, and somehow it's bypassing inappropriate inputs until it gets back around to the next (command) function that feeds in text, and that's the Dimaligned command name for what should be the next segment.  That ought to be the reason it's only doing every other segment.  So I suspect it's interpreting a line segment as an arc, and I can't think of a way that it could except for the same problem I was having, even if it's manifesting itself differently [that may be version-dependent].

 

The attached update includes that provision for the halves of a zero-degree-direction segment being read as 0 and 2 pi instead of both as 0, and also has some other adjustments -- avoidance of coincident vertices that caused trouble in the previous version, and stacking of fractions [if used] in arc-segment dimensions to match those in line-segment dimensions.

 

If that doesn't fix your problem, the next thing I would suggest is to change the fuzz factor in the (equal) functions to something a little cruder than 1e-8, say maybe 1e-6.

Kent Cooper, AIA
Message 26 of 54
Anonymous
in reply to: Anonymous

I am out of the office and just saw your updates. I will check them when I get back.

Thank you very much for you help with this.

Message 27 of 54
arsafe04
in reply to: Kent1Cooper

hi kent you've got a great routine, could you please include an option to select multiple polylines. when dimensioning arcs four decimal places me, can be round two Thank you

Message 28 of 54
Kent1Cooper
in reply to: arsafe04


@arsafe04 wrote:

hi kent you've got a great routine, could you please include an option to select multiple polylines. when dimensioning arcs four decimal places me, can be round two Thank you


For multiple Polylines, I may get back to that later -- I'm on my way out the door, but quickly....

 

For the decimal places, as described at the top of the file, it uses your current Dimension and Units settings.  You can change those to get your two decimal places.  But if you have some reason not to change them, replace this line:

 

                ;; [include mode/precision here if current dimension style's settings not desired]

 

with this:

 

                2 2 ;; <---EDIT mode/precision as desired

 

[that's decimal mode, to 2 decimal places].

Kent Cooper, AIA
Message 29 of 54
caruga1
in reply to: Kent1Cooper

Kent1Cooper thank you for this usefull lisp!

It would be great if you could make it work with more polylines at the same time,

Thank You!

Message 30 of 54
Kent1Cooper
in reply to: caruga1


@caruga1 wrote:

Kent1Cooper thank you for this usefull lisp!

It would be great if you could make it work with more polylines at the same time,

Thank You!


With two such requests now [also @arsafe04 earlier, if they're still watching], I finally got around to adjusting it for that.  I also made its *error* handler viable for newer versions of AutoCAD, and tweaked various other little things.  Remember to EDIT the Dimensioning Layer name and color to suit your standards.

Kent Cooper, AIA
Message 31 of 54
Kyle.Pederson
in reply to: Kent1Cooper

I get an error that says a description was not provided? I'm wanting to use this on a layer called "Dimensions" for the color i'm wanting it to use whatever color the layer calls for.

Message 32 of 54
Kent1Cooper
in reply to: Kyle.Pederson


@Kyle.Pederson wrote:

I get an error that says a description was not provided? I'm wanting to use this on a layer called "Dimensions" for the color i'm wanting it to use whatever color the layer calls for.


 

Since the code contains nothing about a Description, I would have to assume there's something about the way you edited the Layer-making/setting line that's not right.  Post that part of your version.

Kent Cooper, AIA
Message 33 of 54
Kyle.Pederson
in reply to: Kent1Cooper

Kent, I got it working now. I Changed the layer name but didn't alter the color. So originally I was getting my Layer but as a different color. I believe when trying to alter the color I had altered  "_color" to "BYLAYER" when it should have been the "2" I was altering.

 

(command "_.layer" "_make" "Dimensions" "_color" BYLAYER "" "");; <---EDIT Layer name/color as desired

 

How would I add this into a Toolbar Button?

Message 34 of 54
Kent1Cooper
in reply to: Kyle.Pederson


@Kyle.Pederson wrote:

.... 

(command "_.layer" "_make" "Dimensions" "_color" BYLAYER "" "");; <---EDIT Layer name/color as desired

How would I add this into a Toolbar Button?


You can't assign BYLAYER [or BYBLOCK] as the color of a Layer, only as the color of an object.  [And even then, it needs to be in quotation marks -- "BYLAYER".]  If you don't  use the Color option at all in making a Layer, it will be color 7 [white/black].  If you don't want that, you need to give it a number [or a color name, such as "red"].

 

Read up about the CUI command to Customize the User Interface by adding a Toolbar button with it.

Kent Cooper, AIA
Message 35 of 54
Kyle.Pederson
in reply to: Kent1Cooper

little confused and I appreciate the help...

 

So I Have a Layer Called "Dimensions" with a Color of 144. So my code should look like:

 

  (command "_.layer" "_make" "Dimensions" "_color" 144 "" "");; <---EDIT Layer name/color as desired

 

That doesn't seem to work either.....

 

What are the "" "" at the end of the code doing?

 

 

 

Message 36 of 54
Kent1Cooper
in reply to: Kyle.Pederson


@Kyle.Pederson wrote:

....So I Have a Layer Called "Dimensions" with a Color of 144. So my code should look like:

  (command "_.layer" "_make" "Dimensions" "_color" 144 "" "");; <---EDIT Layer name/color as desired

That doesn't seem to work either..... 

What are the "" "" at the end of the code doing?


 

It works for me, used in isolation.  Something else must be going on....

 

In AutoLisp code, "" [an empty text string, i.e. two double-quotes with nothing between them] is used for Enter.  This is duplicating a command-line Layer command, using Enter to accept default values as you would from the keyboard.  The first one is assigning the specified color to the offered-default current Layer, and the second one is ending the Layer command.  The Make option in the Layer command creates the Layer if it doesn't exist [and is not bothered at all if it does already] and sets it current in the process  [as opposed to the New option, which does not], so by the time the color assignment comes along, it's the default offered for the Layer to which to give that color, which means you don't need to spell out the Layer name again for that assignment.

 

If you can be certain that the Layer will always already exist, you can just use the "_set" option, and forget the color assignment:

  (command "_.layer" "_set" "Dimensions" "")

But I always use Make for such things, so I don't have to care whether the Layer in question exists, or maybe did once but has been Purged.

 

[The semicolons and what follows at the end are just commentary -- everything from any semicolon onward is ignored, so you can dump that part.]

 

Kent Cooper, AIA
Message 37 of 54
Kyle.Pederson
in reply to: Kent1Cooper

it is working now! I was just copying and pasting the code into the command line. that seemed to have an issue. When I load the .lsp through "Load Application" it seems to work just fine. Appreciate your help and patience!

Message 38 of 54
mfuentes89MW3
in reply to: Kent1Cooper

 
 
Hello, the routine is very useful. One question please, what should I do so that the dimensions of the arcs have only two decimal places or how to choose the number of decimal places?
Thanks
Message 39 of 54
CodeDing
in reply to: mfuentes89MW3

@mfuentes89MW3 ,

 

Welsome to the forums!

 

Have you tried adjusting your Dimension Style in your Dimension Style Manager to reflect 2 decimal places?

 

Best,

~DD

~DD
Senior CAD Tech & AI Specialist
Need AutoLisp help? Try my custom GPT 'AutoLISP Ace':
https://chat.openai.com/g/g-Zt0xFNpOH-autolisp-ace
Message 40 of 54
mfuentes89MW3
in reply to: CodeDing

Yes, I tried, but nothing happens. The dimension in the arc is a 3 point angular type, not the arc length, perhaps that is the problem? thanks

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

Post to forums  

Autodesk Design & Make Report

”Boost