& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
Hello!
Can you help me to find way to create linked objects in AutoCad from C#?
I mean - for example, circle and some lines lined to this circle:
- If I move line it should be possible to move only one end point of line - second endpoint should be linked to the circle and not moved.
- If I move circle it should be move all endpoints of all lines linked to this circle.
In general I want to create network diagramm ("graph" in mathematical terms) from C# code.
Is it possible? May be anybody has code exapmle?
Thanks again,
Pavel.
You might be able to do it with Jig or TransientGraphics or Overrule, or combination of them. Be warned, though, that all of them are quite advanced Acad .NET programming topics. And, TransientGraphics is onlay available since Acad2009 and Overrule is only available since Acad 2010.
Thanks for quick answer. 2010+ is good for me.
But what overrule should I use? TransformOverrule, GeometryOverrule or ...?
Pavel.
Hi,
If you need topological analysis, you can resort to AutoCAD Map and it's API that you can partner with Oracle Spatial (via FDO) to store topological data and even create topological querys and analysis, or you can get a class library like this :http://quickgraph.codeplex.com/, it have a comprehensive tool set oriented to graph creation, analysis, traversal and almost anything you need to do with a graph. Also you can create your own graph structure (a class or a struct), but you will have to implement all the rest (searching, traversing, up/down stream search, weights, etc).
Actually I'm using the quickgraph library in a concrete formwork solution with very good results (performance, stability, etc).
Gaston Nunez
Thanks! I known about quickgraph at codeplex. I agree that it's good library!
But... my current task is to create graph in AutoCad. Concrete - allow user to insert it in AutoCAD.
Pavel.
If you want to program this yourself, then overrules and/or constraints may help you. Take a look at the two AU classes of mine mentioned in Kean's blog here - http://through-the-interface.typepad.com/through_the_interface/2010/12/some-content-from-au-2010.htm.... The Overrule class includes a demo of a simple 'network' application I wrote.
Thanks for your example! But it's not exactly I want.
It's "virtual" polyline between circles. It's good, but I can't edit this polyline.
Is it possible to lock position of one point of line/polyline at all? May be with TransformOverrule or so on?
Result is that I can't move one point of line and can move other and change properties.
Thanks,
Pavel.
I did it! Thanks all.
Pavel.
Although you have solved your issue, you may still be interested in a post I just published, which was inspired by your question. Comments and critics are welcome.
http://drive-cad-with-code.blogspot.ca/2012/08/creating-linked-entities-with-drawjig.html
Norman, your code is very interested. But... As I understand you use not "real" lines for shown links - so user can't edit it. In my task I want to create real polyline and allow user to edit it except start and end points because they are linked.
Thanks!
Pavel.
@Anonymous wrote:
I did it! Thanks all.
Hi Pavel,
Perhaps you'd like to share with us how you solved the problem. Did you use constraints or some other mechanism?
Hi Stephen,
What I did:
1. On db.ObjectAppened I create ExtendedDictionary for new object and set obj.Modified event handler.
2. I have special command for add nodes (DBPoint) and lines (Line). When I add line I fill ExtendedDictionary for nodes where line started and ended.
3. In Modified handler I move all linked objects to the new position.
Also, I have handler for db.ObjectErased and clear ExtendedDictionary if line was removed.
Not resolved issue: how to prompt user to select point on the screen or object. I can use PromptPointOptions for point selection and PromptEntityOptions for node selection, but I want to enter point if it's not linked line or node if it's linked line. Now I use PromptPointOptions and check it by coordinate.
Pavel.
P.S. It's very strange that when I set Modified event this event raised. Also strange that ExtendedDictionary is not Dictionary and I should enumerate it to create real Dictionary.
Thanks for sharing. The disadvantage of your approach is that the geometric relationships will be lost if someone edits your drawing without your app loaded. I believe a good alternative is to use the Parametric Drawing feature/API - that's a combination of geometric and dimensional constraints. But if you're happy with your solution, then no point in prolonging the discussion.
Off the top of my head - maybe the Editor.PointMonitor event will help you for your other problem.
Hi Stephen,
Thanks for your support and this discussion. I can't say that I'm fully happy with my solution because it is required to create more handlers - if user add/move/delete objects (it's ok) but also - undo/copy/paste and so on... All of it I should handle.
I'll check your proposal about Parametric Drawing API. I saw that it's possible to set geometric constrains in blocks. May be I can use such constrains in the schema.
Pavel.
Stephen,
May be you have C# examples to create position (geometric?) constraint between two objects?
Pavel.
I posted a link to my AU class on parametric drawing API earlier in this thread. I can't remember if the samples are C#, or VB.NET, or both - but the API calls are the same and easily translated using an online translator.
I decice to stay with my solution because user can see constrains and delete it, but can't delete overrules.
Thanks,
Pavel.
Hi Pavel,
i am trying to work on a similar task that you have posted but the problem that i am not familiar with advanced autocad programming .
Appreciate any help with a sample code or a link for the solution
Best Regards, jack
--------------------------------------------------------------------------------
i am trying to work on a similar task that you have posted but the problem that i am not familiar with advanced autocad programming .
--------------------------------------------------------------------------------
Hi jack,
I'm also is not expert in AutoCad. It seems I'm junior novice 🙂
I can't public full code becuase it's prived code of my customer.
This main idea of my solution is very simple: store linked object handles in ExtendedDictionary and add Modify event handler. In this handler I have new postion of object and get handles of linked object and move all of it.
Additiona I should hadnle copy and delete events with the help of ObjectOverrule because I should clear ExtendedDictionary for copyed objects.
About ExtendedDictionay storage: http://adndevblog.typepad.com/autocad/page/17/
DrawOverrule: http://through-the-interface.typepad.com/through_the_interface/2009/04/customizing-the-display-of-st...
Post you questions here if I can help.
Pavel.
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name