*Expert Elite*
Posts: 2,519
Registered: ‎05-21-2008
Message 1 of 11 (399 Views)

# Profile / alignment label expression

399 Views, 10 Replies
11-26-2012 01:48 PM

Here is my expression:

IF((FMOD({Raw Station}+5,15))!=0,-1,({Profile Elevation}-100*FLOOR({Profile Elevation}/100)))

I have also tried it without a pair of brackets:

IF((FMOD({Raw Station}+5,15))!=0,-1,{Profile Elevation}-100*FLOOR({Profile Elevation}/100))

and I have tried it using {Station Value} instead of {Raw Station}

Here's what it's meant to do (because it's a long one):

If the station value + 5 is not divisible by 15, return -1

If the station value + 5 is divisible by 15, return the profile elevation,

if the proile elevation is in the 100 range, subtract 100

if the proile elevation is in the 200 range, subtract 200...etc

Here is my conundrum: If I use the expression in a profile label, it works fine.  But if I use it in an alignment label as refference text, it returns -1 for every value.

Credit where credit is due! Give kudos or accept as solution whenever you can.

*Expert Elite*
Posts: 2,519
Registered: ‎05-21-2008
Message 2 of 11 (369 Views)

# Re: Profile / alignment label expression

11-28-2012 05:36 AM in reply to: troma

Possible reasons why I haven't got a reply yet:

1. I didn't explain the problem very well.

2. I didn't explain that this is really frustrating.

3. Nobody can think of a good reply.

4. Nobody cares.

5. Sinc is sick.

6. A butterfly flapped its wings in the gulf of Mexico.

Credit where credit is due! Give kudos or accept as solution whenever you can.

*Expert Elite*
Posts: 4,193
Registered: ‎07-22-2003
Message 3 of 11 (364 Views)

# Re: Profile / alignment label expression

11-28-2012 06:50 AM in reply to: troma

7. Many of us are in Las Vegas with little time to check the forums.

Can you post a drawing showing the problem? This would make it far easier for someone to see what is going on and possibly offer a solution.

Jeff_M, also a frequent Swamper
*Expert Elite*
Posts: 2,519
Registered: ‎05-21-2008
Message 4 of 11 (358 Views)

# Re: Profile / alignment label expression

11-28-2012 10:41 AM in reply to: Jeff_M

Jeff, I hadn't thought of that!

So, I was going to take your advice, but I didn't want to post the drawing with private info.  So I started a new drawing from an almost emply template we keep on hand and dragged the styles over.  I set up an alignment and profile to show off the problem, and the labels worked!  So now I have to troubleshoot by playing spot-the-difference between these two templates.

Credit where credit is due! Give kudos or accept as solution whenever you can.

*Expert Elite*
Posts: 2,519
Registered: ‎05-21-2008
Message 5 of 11 (333 Views)

# Re: Profile / alignment label expression

12-03-2012 06:39 AM in reply to: Jeff_M

Ok, I had to do other stuff for a while, but I've just managed to get back into this and do some testing.  Here are my observations so far:

Being near or far from the origin has no effect.

Alignment created by layout or from polyline makes no difference

Other differences with the alignment do have an effect:

If the alignment is a straight line in an ortho direction, the labels work fine

If the alignment contains a PI but both segments are drawn in ortho directions, the labels work fine

If the alignment is a straight line in any other direction, the labels don't work

If the alignment is or contains an arc, the labels don't work.

Admitadly I haven't tested all possible options here, this is kinda preliminary.  But I think I've found why the labels worked in my previous brief test, but don't work in real life.

Attached drawing in C3D 2011.  I'll be interested if this label works better if created from scratch in a newer version too, but that won't really help me.

Credit where credit is due! Give kudos or accept as solution whenever you can.

*Expert Elite*
Posts: 2,519
Registered: ‎05-21-2008
Message 6 of 11 (328 Views)

# Re: Profile / alignment label expression

12-03-2012 08:04 AM in reply to: troma

If anyone is wondering why I've created an expression to return -1 for two-thirds of the stations, I'm actually trying to make use of BrianHailey 's method of hiding specific labels as mentioned here:

http://civil3dplus.wordpress.com/2012/06/25/label-every-insert-interval-contour-line/

I want to label stations 1+000, 1+015, 1+030 etc.

I originally tried an expression to give my text a zero height for the unwanted stations, but that doesn't work as discussed here:

Credit where credit is due! Give kudos or accept as solution whenever you can.

*Expert Elite*
Posts: 4,193
Registered: ‎07-22-2003
Message 7 of 11 (325 Views)

# Re: Profile / alignment label expression

12-03-2012 09:18 AM in reply to: troma

OK, I'm seeing the same strangeness in C3D2012. I created an expression that returns just the FMOD({Raw Station} + 5, 15) and in all the cases where no profile elevation is returned, but you think it should be, the value is 15.0000 and not 0 as expected. Definitely looks like a bug in the FMOD function.

Jeff_M, also a frequent Swamper
*Expert Elite*
Posts: 2,519
Registered: ‎05-21-2008
Message 8 of 11 (322 Views)

# Re: Profile / alignment label expression

12-03-2012 09:40 AM in reply to: Jeff_M

Thanks Jeff, so I'm not crazy!

Can you think of any other way of getting where I'm trying to go?  Looking for a detour, since this road is blocked....

Credit where credit is due! Give kudos or accept as solution whenever you can.

*Expert Elite*
Posts: 2,519
Registered: ‎05-21-2008
Message 9 of 11 (315 Views)

# Re: Profile / alignment label expression

12-03-2012 10:12 AM in reply to: troma

I thought I was getting somewhere with

(({Raw Station}+5)/15)-ROUND(({Raw Station}+5)/15))

but when I include it in an IF statement it doesn't seem to work.

Credit where credit is due! Give kudos or accept as solution whenever you can.

*Expert Elite*
Posts: 2,519
Registered: ‎05-21-2008
Message 10 of 11 (310 Views)

# Re: Profile / alignment label expression

12-03-2012 10:41 AM in reply to: Jeff_M

(1-10*(SQR((({Raw Station}+5)/15)-ROUND(({Raw Station}+5)/15))))*(({Profile Elevation}-100*FLOOR({Profile Elevation}/100)))

No if statement, no FMOD function.  In the first part it manages to return the number 1 for the wanted stations, and -0.1 for the unwanted.  It then multiplies this by the desired elevation, returning a negative elevation for the unwanted stations.  I can then use a "hide negative values" option in the label style.

Tested, working.

Thanks Jeff for figuring out that it was the FMOD causing me grief.

Credit where credit is due! Give kudos or accept as solution whenever you can.

### You are not logged in.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

### Maintenance Subscription Resources

Upgrading to a 2015 product? Make sure to check these out 1st!

### Civil 3D Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for AutoCAD Civil 3D helps you achieve greater speed, accuracy, and automation from concept to manufacturing.