Python and Civil 3D API - Seeking Guidance on Custom Nodes

Hello everyone,

I’m currently facing an issue with my Python script that requires the integration of two nodes that are either missing from the standard node library or not functioning correctly.

  1. SubassemblyTargetInfo.SetTargetsOption: This node is available in the Civil3DToolkit, but unfortunately, it isn’t working as expected. I found an issue related to this on GitHub (Civil3dToolkit Issue #79).
  2. SubassemblyTargetInfo.UseSameSideTarget: This node is theoretically present in the Civil 3D API (version 2024.4) as indicated in the Autodesk documentation (link). However, Python seems completely unresponsive to it.

Moreover, I’m unable to use the setter for SetTargetsOption as I receive the following error: “TypeError: Property is read-only.” Am I missing a crucial step here? Do I need to unlock or somehow modify the SubassemblyTargetInfo object to make it writable?

For context, I can successfully retrieve properties such as LogicalName and DisplayName from SubassemblyTargetInfo at IN[0] without any issues.

I’ve attached a screenshot of a portion of my code below. I would greatly appreciate any guidance or suggestions on how to resolve these challenges.

Thank you in advance for your help!

Hi @mchn,

Any chance you’re able to update to Civil 3D 2025.1? Both of these nodes are available out of the box.

Unfortunately, no, as I heavily rely on Alignment.CreateConnectedAlignment from the Arkance Systems package (and it no longer works in 2025.1). Additionally, the client is not too keen on upgrading to the latest versions.

I’ve been trying to find a workaround, and I’ve tested new nodes from 2025.1.

Is there a reason that Elevation type Targets does not accept “Nearest”?

If I set it up manually, I can actually achieve what I want. But I can’t do it through the newest Dynamo for some reason?

Hmm…that seems odd. Let me dig into it and see what’s going on. The output from List.Flatten only contains offset or elevation targets, correct?

Yup - nearest and farthest does not work for elevations for some reason

Yep, that’s a bug. Thanks for flagging this, and sorry for the hassle. You can expect a fix in the next Civil 3D update.

Is there any viable workaround through API or anything like this? It pretty much nulls the whole script.

Do you need a workaround in 2025.1, or for the earlier version that you were working with first?

At this point I’m open for 2025.1, as I might split the script into two - one part is done in 2023/4, the other one in 2025.1. Not an elegant solution, but a solution nevertheless.

I need XXX.UseSameSideTarget (seems to work fine in 2025.1) and XXX.SetTargetsOption. Ideally in 2024.4, but if there’s a quick solution in 2025.1 you might be aware of, I’d be happy with it.

Thank you for looking into it!

Could you give a little more insight into what your end goal is? I think that would help. Looking at your original screenshot, it looks like maybe you’re trying to set the properties for all targets that match some criteria?

I’m working on a script to generate connections to the main road, including curves, in a standardized and automated way based on a set of input data and a series of Alignments. Because these connections involve curves, generating the Curb Alignment is essential for me.

The final step of the script is to assign Targets while considering variable geometry, followed by generating a solid. That’s why I need the “Nearest” option—it helps to prevent anomalies like the ones shown in the screenshot (they do not exist if “nearest” is chosen manually).

image

Apologies for the self-bump. @mzjensen I was wondering if you’ve managed to find any solution to this issue? At this point, the only thing I can suggest is waiting for the 2025.2 release. Do you happen to know when it’s expected to come out?

Sorry @mchn, there have been a lot of demands on my time lately. Apologies for the delay!

The trick with this API is that after setting the target values, you need to reapply the SubassemblyTargetInfo object back to the region with the BaselineRegion.SetTargets() method. Keep this in mind as well :point_down:

image

I do, but per company policy I am not able to give specific release timelines. However, you may be able to review our prior release history and arrive at a reasonable estimate :wink:

1 Like

Thanks so much for the follow-up! I’ve tried to apply the approach you suggested—my first screenshot shows what each of the variables is producing.

The second screenshot already shows the result after enabling the highlighted line of code.

I would greatly appreciate your help in figuring out what I’m doing wrong here. I’m attaching the script and DWG file.

04_NearestTargets_(C3D2025)_01.dyn (47.4 KB)
DWG: Unique Download Link | WeTransfer