AutoCAD Civil 3D General Discussion

AutoCAD Civil 3D General Discussion

Reply
*Expert Elite*
troma
Posts: 2,524
Registered: ‎05-21-2008
Message 1 of 11 (463 Views)
Accepted Solution

Profile / alignment label expression

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

 

All suggestions gratefully received!


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

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.

How about this!:

 

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

*Expert Elite*
troma
Posts: 2,524
Registered: ‎05-21-2008
Message 2 of 11 (433 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*
Jeff_M
Posts: 4,472
Registered: ‎07-22-2003
Message 3 of 11 (428 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*
troma
Posts: 2,524
Registered: ‎05-21-2008
Message 4 of 11 (422 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*
troma
Posts: 2,524
Registered: ‎05-21-2008
Message 5 of 11 (397 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*
troma
Posts: 2,524
Registered: ‎05-21-2008
Message 6 of 11 (392 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:

http://forums.autodesk.com/t5/AutoCAD-Civil-3D/Alignment-Label-with-Reference-Text-amp-Expressions/m...

 

 


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

*Expert Elite*
Jeff_M
Posts: 4,472
Registered: ‎07-22-2003
Message 7 of 11 (389 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*
troma
Posts: 2,524
Registered: ‎05-21-2008
Message 8 of 11 (386 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*
troma
Posts: 2,524
Registered: ‎05-21-2008
Message 9 of 11 (379 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*
troma
Posts: 2,524
Registered: ‎05-21-2008
Message 10 of 11 (374 Views)

Re: Profile / alignment label expression

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

How about this!:

 

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!