Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

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

C# .NET - The start and end station should be in the range of baseline.

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
izzybabur
1182 Views, 3 Replies

C# .NET - The start and end station should be in the range of baseline.

Hi, 

 

I have made a customized command that creates numerous baseline regions for use with different custom subassemblies. It works perfectly fine on a shorter alignment (400m length), but not on my long alignments (varies between 10km - 30km). 

 

I get the following error:

 

************** Exception Text **************
System.ArgumentException: The start and end station should be in the range of baseline.
at Autodesk.Civil.DatabaseServices.BaselineRegionCollection.Add(String regionName, ObjectId assemblyId, Double startStation, Double endStation)
at GettingStarted.MainClass.CreateBaselineRegions() in C:\Users\mohammed.babur\Documents\Visual Studio 2015\Projects\GettingStarted\GettingStarted\MainClass.cs:line 142
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()

 

 

I can't seem to find out what's wrong with it, especially since it's working just fine with my other alignments. 

 

Here's an overview of my workflow in C# .Net :

 

  1. User selects an alignment
  2. User selects a profile
  3. User selects Assembly 1 (custom subassembly made with SAC 2017)
  4. User selects Assembly 2 (custom subassembly made with SAC 2017)
  5. User selects Assembly 3 (custom subassembly made with SAC 2017)
  6. User specifies baseline region parameters
    • Continuous region for Assembly 1 throughout the alignment length (no option for user to change this)
    • Continuous region for Assembly 2 throughout the alignment length (no option for user to change this)
    • Discontinuous region for Assembly 3 (user specifies how long each region should be, and what the spacing should be between each region)
      • think of this as columns under a continuous bridge deck (assembly 1), with continuous earthworks (assembly 2) along the alignment
  7. Start transaction
  8. Create corridor using the user specified alignment (step 1), profile (step 2), and first assembly (step 3)
  9. Open new corridor for write
  10. Add baseline to corridor with the same user specified alignment and profile 
  11. Add a baseline region to the baseline using the second assembly (step 4)
  12. Add another baseline using the same user specified alignment and profile
  13. Open the user specified alignment (step 1) for read
  14. Get the start station
  15. Get the end station
  16. Define the alignment length (end station - start station)
  17. Round length DOWN to the decimal place and convert it from a double to an integer
  18. Define the start and end station for the first iteration to create the baseline regions
    • Define the start station as equal to the alignment start station (from step 14) 
    • Define the end station as equal to the alignment start station (from step 14) plus the length of the baseline region specified in step 6
  19. Define the number of iterations (length from step 17 divided by spacing specified in step 6)
    • I also brought this result down to the nearest decimal place and converted it to an integer
  20. Start iterations with for loop from first iteration until the number of iterations is complete (step 19)
    • Add a baseline region using Assembly 3 (from step 5), with the first start station and end station
    • Define new start station as the end station plus the spacing specified in step 6
    • Define the new end station as the start station plus the length of the region specified in step 6
  21. Commit changes and end transaction

 

All of this works great on a short alignment, but on my longer ones, I get the system argument exception.

 

Would be nice to know if I'm just doing something silly here. I would love to post my code here, but I'm hesitant as it may violate our NDA Policy.

 

Any help would be greatly appreciated!

 

Thanks,

 

izzy

3 REPLIES 3
Message 2 of 4
Jeff_M
in reply to: izzybabur

Have you tested this during a debug session so you can look at the values being used? It should break when the exception is thrown and allow you to make edits (if Edit & Continue is enabled). This is how I typically find where I didn't account for something, or have an error in my indexing.
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 4
izzybabur
in reply to: Jeff_M

Hi Jeff,

 

I just ran a debug (silly me, didn't think it would actually show the numbers).

 

Please see attached some screenshots of the error and the bottom panes in MS Visual Studio. 

 

At first glance, it looks like my final iteration is 0.04m longer than the alignment length. I'll take a few minutes here to digest the code in the meantime and see if I can find a way around this. Perhaps an if statement which prevents the baseline region from being created if the difference between the start and end station of the final iteration is smaller than the extrusion thickness specified by the user (step 6 in first post of this thread).

 

Thanks,

 

izzy

Message 4 of 4
izzybabur
in reply to: izzybabur

Jeff,

 

I believe I found the issue.

 

My iteration stopped at iteration 1207 of 1255. This was because I did not account for the extrusion thickness within the baseline regions when setting up the number of iterations.

 

Best way to picture this:

 

Imagine a bridge deck which is 1000m long, and has 25m long substructure (column and pier) span lengths. The total substructure width is 1m wide. 

 

I set the number of iterations as 1000m / 25m. However, this doesn't account for the columns being 1m wide, so as you go up in your iterations, your last few span lengths are actually consumed by the cumulative column widths. 

 

It should be (1000m/25m) is the center to center spacing of the columns. But the columns are 1m wide, so you have to account for that 1m adding up along the alignment, especially if I want to create baseline regions in between the spans and not from center to center of spans. 

 

I rewrote a portion of the code to calculate the cumulative column length, subtract that from the total, and recalculate the number of span lengths from edge of column to edge of column (not center to center). 

 

Now it works great! Except my surface is not densely populated with points, so I get a bunch of missing target errors along the alignment.

 

Thanks again for the debugging suggestion it really helped!

 

Cheers,

 

izzy

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

Post to forums  

Rail Community


Autodesk Design & Make Report