TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: tdeleske on June 07, 2022, 10:34:58 AM

Title: Help with lisp complex insertion point for label
Post by: tdeleske on June 07, 2022, 10:34:58 AM
Hello, I have inherited an old piece of code that I am trying to make better as we still use it.
the story is.. the routine(s) are for labeling bearings and distances with scale factor as annotative mtext,
the issue is the insertion point part is complex and I am hitting a wall trying to figure it out.
I have the insertion point location scaled by the current annotation scale so it acts like a Civil 3d Label with distance offset from a line to be varied based on the cannoscale setting.
there are a number of commands within the code, so I am focussed on (defun c:LabelDistance command.
so at 1:1000 I have the insertion point offset @ 1, if 1:5000 the offset is 5... but its not placing it perpendicular from the midpoint.
what I am trying to achieve is to have the distance offset perpendicular from the midpoint of the line..
any guidance would be greatly appreciated.

Regards

Trevor
Title: Re: Help with lisp complex insertion point for label
Post by: tombu on June 07, 2022, 12:41:48 PM
Using cannoscalevalue to size and place text should be as simple as (/ 0.1 (getvar 'cannoscalevalue)) or height you want text to plot divided by (getvar 'cannoscalevalue).
System variables like USERR2 could have conflicts with any other code that uses them.
If you used MC justification for the Mtext the offset would be the same for above & below the line simplifying the code.
You'd probably have better luck entmaking the Mtext rather that using a command call.

As the code references UTM coordinates are you using Map 3D or Civil 3D? You may have better options for labeling built in. I have old code for labeling line and arc segments from before we upgraded to Civil 3D years ago.
Title: Re: Help with lisp complex insertion point for label
Post by: tdeleske on June 07, 2022, 01:03:13 PM
Thanks for the feedback Tom.
there is probably a pile of coding blunders within.. it has been through many hands over the years, so really just looking for a band-aid solution.
We are using Civil 3D 2020 and do use Civil 3D label styles with the Scale Factor version when appropriate, details and visibility of the label are the issue.
Civil 3D labels have limitations regarding visibility and annotation scale when you have many details that need to restrict a label from the view, can't freeze the layer as other things are on the same layer, and can't restrict by annotation scale because Civil objects are all scales, so we use this custom routine that outputs current scale annotative mtext to serve the need.

you mentioned alternatives... is there some OTB labeling for Bearings and Distances other than the Civil 3D ones?

Kind Regards
Trevor