Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Profile / alignment label expression

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
troma
750 Views, 10 Replies

Profile / alignment label expression

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!


Mark Green

Working on Civil 3D in Canada

10 REPLIES 10
Message 2 of 11
troma
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.


Mark Green

Working on Civil 3D in Canada

Message 3 of 11
Jeff_M
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
EESignature
Message 4 of 11
troma
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.

 


Mark Green

Working on Civil 3D in Canada

Message 5 of 11
troma
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.


Mark Green

Working on Civil 3D in Canada

Message 6 of 11
troma
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...

 

 


Mark Green

Working on Civil 3D in Canada

Message 7 of 11
Jeff_M
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
EESignature
Message 8 of 11
troma
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....


Mark Green

Working on Civil 3D in Canada

Message 9 of 11
troma
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.


Mark Green

Working on Civil 3D in Canada

Message 10 of 11
troma
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.


Mark Green

Working on Civil 3D in Canada

Message 11 of 11
Jeff_M
in reply to: troma

Wow, now that's a brain teaser! Glad to have been of some help!

Jeff_M, also a frequent Swamper
EESignature

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

Post to forums  

Rail Community


Autodesk Design & Make Report