C# .NET API - How to create alignment regions?

C# .NET API - How to create alignment regions?

izzybabur
Advocate Advocate
4,600 Views
6 Replies
Message 1 of 7

C# .NET API - How to create alignment regions?

izzybabur
Advocate
Advocate

Hi,

 

I'm a newbie to the .NET API and have been reading quite a few help and support documentation on the .NET API. Sometimes it feels overwhelming, so I thought I would reach out and see if what I'm looking to do has already been done. My preferred language is C#. 

 

I'm trying to take a long alignment (50+ km's) and automatically divide it into regions with a set spacing, for example 25m. Is there a way in the API to read the alignment start station, and create an alignment region based on an offset from that station? 

 

For example, if I have a 1 km alignment, can I do the following:

 

  1. Get alignment object, read alignment start and end station.
  2. Set first region from start at 0+00m to 0+25m
  3. Set next region from 0+25m to 0+50m
  4. Continue steps 2-3 until end station has been reached, in this case 975+25m.

It would also be awesome if these regions showed up on my corridor creation dialog box as well.

 

The next step would be to set different region offsets, i.e. 1m then 25m then 1m then 25m, and in the corridor creation dialog box, group all the regions by their length (i.e. all the 1m regions grouped together and all the 25m regions grouped together). Anyway, that's a while down the road but would be pretty awesome if that worked!

 

Thanks for taking the time to read my post, and any help or suggestions would be appreciated!

 

Regards,

 

izzy

 

0 Likes
Accepted solutions (1)
4,601 Views
6 Replies
Replies (6)
Message 2 of 7

Jeff_M
Consultant
Consultant

Hi izzy. Yes, this is all possible. However, I's not really something that should be done as one of your first projects. A good understanding of .NET in general, then the AutoCAD API, and finally the C3D API would be a prerequisite, IMHO.

 

First you would need to get, or create, the corridor object. To group the different sized regions you will need a separate baseline for each. 

Create the Baselines.

Then just add regions to the Baselines, using an indexer for the stations. 

 

Seems simple, but there is a bit of code involved. If you take a stab at it, and post what you come up with, I'm sure you will get some pointers on how to proceed, or correct any issues you may run into.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 7

izzybabur
Advocate
Advocate

Hi Jeff,

 

Thanks for your response, I appreciate it! 

 

I have used .NET in the past quite often (just been a while now though), and I'm still in the process of familiarizing myself with the AutoCAD and C3D API. I've tried a .NET few tutorials for making points, lines, geometries and turning polylines into alignments, etc. 

 

I think I understand the workflow that you've described, and I'll give it a shot. If I get stuck I'll try some more tutorials and then give it a shot again! And lastly, I will post my code in this thread to get pointers as you suggested.

 

Thanks again!

 

izzy

0 Likes
Message 4 of 7

izzybabur
Advocate
Advocate

Hi Jeff,

 

One more quick follow-up:

 

I wanted to share a screenshot of the process I'm looking for, and if you could provide some guidance if I have the right idea for workflow.

 

For my purpose, I will already have a centerline alignment, an existing ground surface, and a design profile. I have a number of custom subassemblies I've created with the SAC 2017 that I would like to use. However, in the screenshot, I just ran a quick workflow test with subassemblies created from polylines. 

 

In the screenshot, the "BL - Tube" baseline is pretty straight forward in the sense that I want it to be continuous throughout my corridor. The other baseline, "BL - Sub", has multiple regions as it will be drawing my substructure elements which are not continuous. In the screenshot, I have just one assembly I'm using there, but it will actually be an assembly that changes shape based on a surface target. As you can see, start and end station of the sub regions are 1m long. I want this distance to be input by the user. 

 

Based on the workflow of manually doing the process for a few iterations in Civil 3D, here's what I'm thinking for the .NET workflow:

 

  1. Create corridor object from user specified alignment and profile.
    • I would like to prompt the user to select the alignment and select the profile
    • Get the alignment and profile
    • Create the corridor
  2. Create first baseline for the tube
    • Prompt the user to specify which assembly to use
    • Get the assembly
    • Create baseline for entire corridor length with the user specified assembly 
  3. Create second baseline for the substructure components
    • Prompt the user to specify which assembly to use
      • This would be the conditional subassembly I've created in SAC 2017, which has a surface target
    • Prompt the user to specify the start station
      • Check if station lies within the alignment range
      • Get station
    • Prompt the user to specify the substructure thickness along the alignment direction
      • Get thickness
        • Side note: this would be the thickness of a column or pier or sleeper (in the alignment direction) when the solids are extracted from the corridor
    • Prompt the user to specify the span length along the alignment direction
      • Get span length
        • Side note: this would be the discontinuity of the substructure components along the alignment (i.e. it would not show as a continuous extrusion along the alignment when the solids are extracted from the corridor)
    • Create a region for the baseline
      • Use the start station that was specified by the user
      • Use the end station as the start station + the thickness specified by the user
    • Create the next region for the baseline
      • Use the previous region's end station + the span length specified by the user as the new start station
      • Use the thickness specified by the user + the new start station as the new end station
    • Continue creating regions for the baseline until the global end station of the alignment has been reached
      • It doesn't matter to me if the end station doesn't contain a substructure element right at the last station
    • Set all targets for this baseline and all regions within it
    • Set all frequencies for this baseline and all regions within it
      • I would like the frequency to be a maximum of the user specified thickness, preferably, at least half the thickness
  4. I would prefer at this point to have the corridor properties dialog box opened for inspection before rebuilding the corridor. 

 

Sorry for the long post, but let me know what you think and if you have any suggestions. I didn't go into too much detail about the actual coding for each point, but I'll be using the tutorials and some internal PLM support as much as possible to get me through the majority of the coding. 

 

Thanks again for your time and consideration, much appreciated!

 

Regards,

 

Ismaeel

0 Likes
Message 5 of 7

Jeff_M
Consultant
Consultant
Accepted solution
Looks like you've pretty much nailed the workflow. I think that I would be tempted to put this on a form so all the input is done and can be edited prior to building the corridor. You could provide a listbox showing all of the calculated stations for the regions (could even allow editing here), which may void the need for the following. Getting the corridor properties to display before rebuilding may be the only thing that will not be achievable....but I haven't had a need to try it, so not sure about that.
Jeff_M, also a frequent Swamper
EESignature
Message 6 of 7

izzybabur
Advocate
Advocate

Hi Jeff,

 

Thanks for all your input and suggestions - much appreciated! 

 

So I've got all steps to work except for Part 4, which I imagine would be a future step and would incorporate your suggestion of having a dialog box or form. 

 

I checked my code piece by piece while writing it by running Civil 3D and running the netload command. It was a good way to find out how the corridor and baseline and regions were added. Then when I got to the last iterative step, I ran a quick test with a for loop with 5 iterations. It worked great!

 

Now, I have it working along the entire baseline length!

 

The next challenge is to get my earthworks to be conditional along the entire length, but I'll try solving that with the SAC 2017. If I have any issues with that, I'll create a new thread.

 

Thanks again!

 

Cheers,

 

izzy

 

Message 7 of 7

Anonymous
Not applicable
Awsome ideas in this thread! I will try to use the same principles to model properly spaced railway sleepers. Thanks for the sharing.
0 Likes