.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create linked objects (for network diagramm)?

22 REPLIES 22
Reply
Message 1 of 23
pva75
1549 Views, 22 Replies

How to create linked objects (for network diagramm)?

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.

Tags (2)
22 REPLIES 22
Message 2 of 23
norman.yuan
in reply to: pva75

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.

 

 

Message 3 of 23
pva75
in reply to: norman.yuan

Thanks for quick answer. 2010+ is good for me.

 

But what overrule should I use? TransformOverrule, GeometryOverrule or ...?

 

Pavel.

Message 4 of 23
hgasty1001
in reply to: pva75

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

Message 5 of 23
pva75
in reply to: hgasty1001

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.

Message 6 of 23
StephenPreston
in reply to: pva75

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.

 

Cheers,

Stephen Preston
Autodesk Developer Network
Message 7 of 23
pva75
in reply to: StephenPreston

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.

 

Message 8 of 23
pva75
in reply to: StephenPreston

I did it! Thanks all.

 

Pavel.

Message 9 of 23
norman.yuan
in reply to: pva75

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

 

 

Message 10 of 23
pva75
in reply to: norman.yuan

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.

Message 11 of 23
StephenPreston
in reply to: pva75


@pva75 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?

Cheers,

Stephen Preston
Autodesk Developer Network
Message 12 of 23
pva75
in reply to: StephenPreston

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.

 

 

Message 13 of 23

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.

Cheers,

Stephen Preston
Autodesk Developer Network
Message 14 of 23
pva75
in reply to: StephenPreston

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.

Message 15 of 23
pva75
in reply to: StephenPreston

Stephen,
May be you have C# examples to create position (geometric?) constraint between two objects?
Pavel.
Message 16 of 23

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.

Cheers,

Stephen Preston
Autodesk Developer Network
Message 17 of 23
pva75
in reply to: StephenPreston

I decice to stay with my solution because user can see constrains and delete it, but can't delete overrules.

 

 

Thanks,

Pavel.

Message 18 of 23
jackob85
in reply to: pva75

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

Message 19 of 23
pva75
in reply to: jackob85


--------------------------------------------------------------------------------

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.

Message 20 of 23
Selevkos
in reply to: pva75

Hi Pavel,

 

My purpose is similar to yours. Can you explain how did you solve?

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost