### Author Topic: Civil 3D Custom Curve Label Expression calc with User-defined Scale Factor  (Read 936 times)

0 Members and 1 Guest are viewing this topic.

#### tdeleske

• Mosquito
• Posts: 14
##### Civil 3D Custom Curve Label Expression calc with User-defined Scale Factor
« on: March 11, 2022, 01:05:48 PM »
Hello, We have been using General Segment Grid Distance Properties and Civil 3D labels for straight lines, we would like to use the same thing with Curve Distance and Curve Radius, but there are no Grid Distance Properties available in the Curve label section in Civil 3D. I am new to creating expressions but gave it a go based on what I could find on the topic online. I found that a custom expression could be created for this but no expression was provided.

I have part of the concept proven here but I am simply typing in a number to see if the calculation works and it does.
not wanting the user to have to edit that expression each time they want to use that label style is preferred, what I need is how to pass the already set User Defined Scale Factor value from Drawing Settings replacing the number I typed in (1.2)

1.2*{General Segment Length}

any guidance would be greatly appreciated!

Regards

Trevor

#### Jeff_M

• King Gator
• Posts: 4037
• C3D user & customizer
##### Re: Civil 3D Custom Curve Label Expression calc with User-defined Scale Factor
« Reply #1 on: March 11, 2022, 03:14:02 PM »
Trevor, you can do this with a small .NET app. The Expressions are not accessible with lisp. Create a curve label expression named GridFactor, give it whatever value you want. Create your other expressions that need to have the scale factor applied (segment length, radius, chord length, etc.) and use the GridFactor in each one. This small app will look for the GridFactor curve expression and update it to the drawing's GridScaleFactor value. The expression is created if it wasn't found. If the ApplyTransformation Setting is not checked, then the GridFactor is set to 1.

Code - C#: [Select]
1.         [CommandMethod("CurveGridFactorExpressionUpdater")]
2.         public void CurveGridFactorExpressionUpdater()
3.         {
4.             var doc = Application.DocumentManager.MdiActiveDocument;
5.             var ed = doc.Editor;
6.             var db = doc.Database;
7.             var civdoc = CivilApplication.ActiveDocument;
8.             var gridscale = 1.0;
9.             if (civdoc.Settings.DrawingSettings.ApplyTransformSettings == true)
10.                 gridscale = civdoc.Settings.DrawingSettings.TransformationSettings.GridScaleFactor;
11.             var expressions = civdoc.Styles.LabelStyles.GeneralCurveLabelStyles.Expressions;
12.             Expression gridExpression = null;
13.             try
14.             {
15.                 gridExpression = expressions["GridFactor"];
16.                 gridExpression.ExpressionString = gridscale.ToString();
17.                 ed.WriteMessage("\n...GridFactor expression updated!");
18.             }
19.             catch
20.             {
22.                 ed.WriteMessage("\n...GridFactor expression created!");
23.             }
24.         }

Small dll attached. Be sure to Unblock the zip file before extracting the file.

#### tdeleske

• Mosquito
• Posts: 14
##### Re: Civil 3D Custom Curve Label Expression calc with User-defined Scale Factor
« Reply #2 on: March 11, 2022, 06:04:12 PM »
Thank you Jeff! I downloaded and tried it out, if I am understanding your description correctly, it's supposed to populate the User-defined Scale Factor field with the value from the gridscale expression if Apply Transformation is selected?
it's not doing that, it does allow me to populate the GridFactor expression with a number and does work in the Civil 3D curve labels.. however...
what I am really after is for that grid factor expression to pull its value number from the User-defined scale factor field that is already populated in every drawing for us,
trying to prevent that step of the user from going into an expression to add a number the daring already knows about.

Kind regards

Trevor
« Last Edit: March 11, 2022, 06:24:21 PM by tdeleske »

#### Jeff_M

• King Gator
• Posts: 4037
• C3D user & customizer
##### Re: Civil 3D Custom Curve Label Expression calc with User-defined Scale Factor
« Reply #3 on: March 11, 2022, 08:51:41 PM »
Thank you Jeff! I downloaded and tried it out, if I am understanding your description correctly, it's supposed to populate the User-defined Scale Factor field with the value from the gridscale expression if Apply Transformation is selected?

Kind regards

Trevor
No, Trevor, it is populating the GridFactor expression with the GridScaleFactor. Just as you are saying you need it to.

#### tdeleske

• Mosquito
• Posts: 14
##### Re: Civil 3D Custom Curve Label Expression calc with User-defined Scale Factor
« Reply #4 on: March 14, 2022, 10:37:57 AM »
Good morning Jeff, I may be missing something, I created a quick screencast to show you what I am seeing.

https://autode.sk/3pYyhTh

Regards

Trevor

#### Jeff_M

• King Gator
• Posts: 4037
• C3D user & customizer
##### Re: Civil 3D Custom Curve Label Expression calc with User-defined Scale Factor
« Reply #5 on: March 14, 2022, 02:27:46 PM »
Trevor, it doesn't automatically update the GridFactor, you must first Netload the dll then run the command CurveGridFactorExpressionUpdater in each dwg in order for the value to get modified. You could add the netload to your acad.lsp file and add the command to your acaddoc.lsp so it gets loads in each session and run when each dwg is opened.

#### tdeleske

• Mosquito
• Posts: 14
##### Re: Civil 3D Custom Curve Label Expression calc with User-defined Scale Factor
« Reply #6 on: March 14, 2022, 07:05:11 PM »
Jeff, thank you very much for your help on this, I have taken your suggestion and added this to our startup package will certainly serve the purpose.

KUDOS!

Regards

Trevor