# Select autocad endpoint in dwg

**URL:** <https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707>\
**Category:** Civil 3D\
**Created:** [November 25, 2020, 10:06pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707 "2020-11-25T22:06:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 25, 2020, 10:06pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/1 "2020-11-25T22:06:04Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/9/3967641e08c15105341833134b35bc6e39d11666.png)

First time using Dynamo, wanted to understand if this type of geometry can be created by selecting lines or polylines in AutoCAD, before I get started. it should also be dynamic.

Thank you  
John

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 25, 2020, 10:31pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/2 "2020-11-25T22:31:23Z")

</div>

Certainly doable - will be much easier with the Dynamo for Civil3D integration. Does the initial (red) curve exist already?

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [November 25, 2020, 10:43pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/3 "2020-11-25T22:43:32Z")

</div>

Like this?

![Offsets](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/2/424ceda9126e4fad36280e4d77f7b52eab27bf48.gif)

---

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 26, 2020, 12:35pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/4 "2020-11-26T12:35:14Z")

</div>

Guys, mzjensen,

yes just like that! does the code select an original line or does the user pick the endpoints for 1 and 2, then it draws that line, and that line is now is dynamic, and controls the prorated spacing of the offset objects.

Q: in Dynamo, what happens when you save the file and you reopen the dwg, do the objects controlled by the code sample, circles in this case ( blocks as I figure how to use this) still stay connected in some way or do you run the code sample again? if you have to rerun code or move the controlling object, what happens to the original objects, are they now static? if the code is rerun, do the old objects need to be deleted. meaning the code is not like an offset civil 3d alignment where you move the centerline object and the connected objects move with it.

Q: can one code graph be use to run another code graph? lets say I have this one do it’s magic, can another code graph be run which gets or uses the original line in it’s new position and run some other code block based on that new location.

Q: I’m guess this same type of code could be used with a polyline, with curves? or would that need additional import. lets say I’m setting utility poles along a roadway centerline and what to set the poles every 100 feet along a centerline, with some offset value. but the start location to start inserting blocks is different then the start location the alignment or controlling object, like civil alignment or polyline, and I need to place poles on one side, I’m guessing you can prompt the user to select a side and a start location. I ask only because I haven’t seen any samples yet that prompt the user.

This type of code interaction looks very promising.

Ok, how do I get started? I guess it’s all about trying samples. when someone posts a graph, and you see a sections that might work for you, is there a way to copy that code? or is it just used to show design flow.

Thank you, this is good stuff.  
John

---

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 26, 2020, 12:36pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/5 "2020-11-26T12:36:58Z")

</div>

btw how do you make the movable images like the one attached?

---

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 26, 2020, 12:51pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/6 "2020-11-26T12:51:41Z")

</div>

Jacob,

No. the idea was to have user pick start and end locations on screen, much like placing a line in AutoCAD, after objects are placed or inserted into the dwg the user can move start or end point to update graphics, circles or blocks.

lets say we use the example below, we are placing utility poles and the spacing variable must have a plus/minus to take into account of terrain or other conditions. user could run different spacing to come up with the best placement solution for there project. I have no idea about utility pole placement, just guessing that’s how it might work.

The goal would be to use an civil 3D alignment, but if the concept is easier to use polylines to flush out the code sample I can use that until I learn how to use the civil objects.

Thank you,  
John .

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 26, 2020, 1:07pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/7 "2020-11-26T13:07:15Z")

</div>

I really appreciate your enthusiasm! Welcome to the community by the way. 😃

> [@jcoon](#):
>
> Q: in Dynamo, what happens when you save the file and you reopen the dwg

You need to rerun the graph to get new results. If the previously created ones are changed depends on if element bindings were created, which is a more advanced topic.

> [@jcoon](#):
>
> can one code graph be use to run another code graph?

Not really, but you could convert your graphs to a custom node and have the results of one custom node inform or trigger the next. There are also ways to have Civil 3D run graphs in sequence via the command line.

> [@jcoon](#):
>
> I’m guess this same type of code could be used with a polyline, with curves?

For the most part - with any attempt to write code there will be some ‘gotcha’ moments.

> [@jcoon](#):
>
> how do I get started

I recommend most people start here if you have Revit access (get a free trial if not): [https://primer.dynamobim.org/](https://primer.dynamobim.org/)  
Skip nothing. Do all exercises even if you don’t think you will need the result. It is about the methods, not the outcomes. There are also AU sessions from 2019 and other resources out there for C3D stuff, but I am a Revit guy at heart. A ‘integration agnostic’ version of the primer has been on my personal wishlist for awhile now, but such an effort is quite time consuming.

> [@jcoon](#):
>
> how do you make the movable images like the one attached?

I use this: [https://www.screentogif.com/](https://www.screentogif.com/)

> [@jcoon](#):
>
> the idea was to have user pick start and end locations on screen

I think it is easier to have Dynamo pick the points rather than the user, or have the user place blocks rather than just click in space at the moment - not sure if there is a ‘pick points on surface’ user interface at the moment. Having the user select an alignment works quite well.

> [@jcoon](#):
>
> lets say we use the example below, we are placing utility poles and the spacing variable must have a plus/minus to take into account of terrain or other conditions. user could run different spacing to come up with the best placement solution for there project.

You just described using generative design, which is one of the most advanced uses of Dynamo at the moment. You can find out more about it by checking out some of the recent AU sessions - ie: I have an example of using it to find the optimal location of a quidditch stadium in my class `Generative Design at Hogwarts: Using Tech Instead of Magic.` Like any advanced topic, best to learn basic Dynamo stuff first rather than jumping into the deep end right away.

---

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 26, 2020, 2:38pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/8 "2020-11-26T14:38:13Z")

</div>

Jacob,

I’ll see what kind of trouble I can get into today playing around with some samples after viewing the primer stuff.

Thanks  
John

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [November 26, 2020, 6:21pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/9 "2020-11-26T18:21:24Z")

</div>

@jcoon here are the files for the quick example I posted earlier.

[Offsets.dwg](https://forum.dynamobim.com/uploads/short-url/rS1XcOMMfc8sLEw9O2d1n87XzGG.dwg) (601.3 KB)  
[Offsets.dyn](https://forum.dynamobim.com/uploads/short-url/zOoMYrzAQEqcySmBGoJTKFpKWNz.dyn) (109.1 KB)

> [@jcoon](#):
>
> does the code select an original line or does the user pick the endpoints for 1 and 2

It just uses a line that is already in model space. I 100% agree with Jacob’s perspective - it will probably be easier to do it this way or something similar such as having the user select and move blocks, circles etc. But if you are really wanting to select the points, then you’ll have to tap into the AutoCAD API using a Python script (example [here](https://forum.dynamobim.com/t/create-point-from-cursor-click-in-civil3d-model-space/45816)). Note that if you ever decide to run the script with Dynamo Player, then you won’t be able to set this as an input (hence the recommendation to use some type of already-created geometry in model space).

> [@jcoon](#):
>
> lets say I’m setting utility poles along a roadway centerline and what to set the poles every 100 feet along a centerline, with some offset value

I put together an example of this for you to try out as you start working with Civil 3D objects. Hope it helps!

[PoleExample.dwg](https://forum.dynamobim.com/uploads/short-url/1Qy2Xc2E1PoTIDoEe4KpLTFvUVQ.dwg) (3.3 MB)  
[PoleExample.dyn](https://forum.dynamobim.com/uploads/short-url/7hyiDHvV65UMiZearJogVwsi5Qn.dyn) (81.6 KB)

![PoleExample](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/3/e3576d969199c0bc65a8a8dc88b316ab4d9f44d9.gif)

---

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 27, 2020, 11:34am UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/10 "2020-11-27T11:34:39Z")

</div>

mzjensen,

This is a fantastic sample, just what I was looking for, a really good real world example.  
let me look at the work flow to see if I can figure out how you did this. I’ll get back to you with questions I’m sure after I take a look…

Thank you,  
John

---

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 27, 2020, 1:57pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/11 "2020-11-27T13:57:43Z")

</div>

MZjensen,

A lot of this looks similar to the old VBA, get current drawing…

what is Math.Floor((end-start)/spacing)+1;? what is that doings? it appears to be reducing the length to  
abs

going to try and add mtext surface elevations at your block (pole) insertions

good stuff!

Thank you,  
John

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [November 27, 2020, 4:03pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/12 "2020-11-27T16:03:22Z")

</div>

> [@jcoon](#):
>
> what is Math.Floor((end-start)/spacing)+1;? what is that doings? it appears to be reducing the length to  
> abs

It’s determining an integer for how many sets of poles there should be. It could be accomplished using multiple standard nodes, but I purposefully condensed it down to a single code block to show an example of DesignScript syntax.

---

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 28, 2020, 2:58pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/13 "2020-11-28T14:58:52Z")

</div>

ok, we are making some headway.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/4/2457700b74b3d8d12fd4f48480420f6d1bcf6a8a.png)  
Here I get your insertion point of the pole, convert surface elevation as double to string for MTEXT label,  
but surface elevation is like 10 place in the decimal, so I used the math.round with a code block =2 for decimal value display level. it does it correctly in the math.round.list, but see second image attached.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/d/8d2b4da1fd82406d4835b5a7013fa038d7c4c454.png)  
It returns the correct decimal value, but its also adding 6 places. can’t seem to find function to make is display only .00 for a value.

I have seen other videos where people are inserting python code to control this, but I don’t know how to insert that type of code block yet.

Q; is there a way to get the point (0) .x value and lets say offset 0.5 in the x direction so that x value or insertion point for mtext is offset from the original .x location of the insertion point of the inserted block.

Thanks you  
John

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 28, 2020, 3:31pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/14 "2020-11-28T15:31:19Z")

</div>

String.Substring will work here.

You will need a string.index of node first as well so you can ID the location of the decimal point.

String.Split could help as well, followed by a List.Deconstruct, a String.Substring node, a pair of + nodes and a few String nodes. Give it a shot and see where you get.

---

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 28, 2020, 4:09pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/15 "2020-11-28T16:09:54Z")

</div>

Jacob,

it seems what you would think is simple is complex, and what you thing is complex is simple.  
most would think the placement of the blocks would be the hard part. the text is proving to be more difficult, I understand the point insertions.

I also looked at the station and offset values, while I can get them, it appears that I need to add a python sample to add the plus sign like you would normally see in C3D, where in vb you could add formatting to do this Is. can you add vb code snips to dynamo?

Dim strSta As String = dStation & prec.ToString()  
Dim strOff As String = String.Format(strOffsetFormat)

strText = "STA: " & (staSTring) & “\P” \_  
& "OFF: " & (strOff) & “\P”

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 28, 2020, 5:34pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/16 "2020-11-28T17:34:22Z")

</div>

Not VB but you can use Design Script or Python. I’m not a Civil 3D user so I have no idea what you are referring to about the +/- stuff, so likely best to start a new topic after marking a solution to the original post here (the original question: can Dynamo build a sequence of offset shapes like this)

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [November 28, 2020, 6:18pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/17 "2020-11-28T18:18:27Z")

</div>

> [@jcoon](#):
>
> I also looked at the station and offset values, while I can get them, it appears that I need to add a python sample to add the plus sign like you would normally see in C3D

Look in the Civil 3D Toolkit package, there is a node for station formatting.

---

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 29, 2020, 1:40pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/18 "2020-11-29T13:40:47Z")

</div>

Jacob,

Sorry, was trying to understand if this type of design tool could help my firm with design automation.  
Most Autodesk products have a point where you must use other tools to complete a specific task outside  
of normal parameters. just asking questions…

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 29, 2020, 5:28pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/19 "2020-11-29T17:28:58Z")

</div>

No worries - questions are good, and the forum exists for you to ask them. We try to keep to a ‘one question per topic’ rule so that other users can easily refer to topics and get answers to questions via search as what isn’t clear to you will likely not be clear to someone else. 🙂

---

<div class="post-metadata">

**Author:** ![jcoon](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcoon](https://forum.dynamobim.com/u/jcoon)\
**Post date:** [November 30, 2020, 2:08pm UTC](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707/20 "2020-11-30T14:08:01Z")

</div>

mzjensen,

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/8/c86d5b8a54014068e5793375ae78cec85b2bd102.png)

Thanks for the hint. was able to add station (+) format.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/c/ec9ab870d595bc1c4c5f6014382bb3ddcd466415.png)

Thank you,

John

[Next page](https://forum.dynamobim.com/t/select-autocad-endpoint-in-dwg/57707.md?page=2)
