dcsimg
Results 1 to 11 of 11

Thread: Integrating AutoCad to VB.Net

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Posts
    253

    Integrating AutoCad to VB.Net

    Is it possible to integrate autocad to vb.net?

    The step by step process of the system that I would like to create would be the following:

    First, using the system I will import the lighting layout plan below

    Name:  1.jpg
Views: 363
Size:  26.8 KB

    Then after the import, the system should recognize the circuits per panel. Using the example lighting layout plan that I have imported above we can see that it has (16/LPP), the one that I have circled using blue ink (see below). It means that in Under LPP panel, we are referring to circuit 16. What I want to happen is whenever the user hover his mouse to the line that belongs to (16/LPP) it should identity whether:
    1. The user added a load description to that particular circuit under panel, which is (16/LPP)
    2. If the user does not add a load description, the system should ask the user to input the necessary information so that we can linked them together.

    Name:  2.png
Views: 335
Size:  74.6 KB

    The circled red ones indicates that it is an object, which in our example is 6 pcs of lighting outlets.



    Below are the sample load descriptions, which the user can enter when the system prompts that that particular circuit does not have any link to load descriptions. As of this time, the user uses excel which he then imports to the AutoCAD, which is one of the things that I want to solve.

    Name:  3.jpg
Views: 331
Size:  69.5 KB

    Below are the sample sketch of the GUI of the system that I want to create

    Name:  4.jpg
Views: 334
Size:  46.7 KB

    It highlighted the ckt no. 16 since the user hover its mouse to the (16/LPP) of the imported autocad.
    The problem that I am trying to solve by proposing this system are the following:
    1. The autocad and load schedule descriptions are not linked together
    2. Minor changes to the load description (using excel) should also done by the user to the autocad, it consumes a lot of time because every project has many revisions and most of the time when the user forgets to revise the other part it leads to confusion due to the inconsistency of the data.

  2. #2
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    588

    Re: Integrating AutoCad to VB.Net

    Have you looked at the AutoCad API? Quite a bit of info on their website.

  3. #3
    Addicted Member
    Join Date
    Jan 2016
    Posts
    153

    Re: Integrating AutoCad to VB.Net

    you can do a lot in AutoCAD with vb.net. You should make use of the AutoCAD vb.net forums for questions.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Posts
    253

    Re: Integrating AutoCad to VB.Net

    As of now I've cut the entire project into the following milestones or steps

    1. Integrate AutoCad to VB.Net.
    2. Look for ways to import an existing AutoCad project to the VB.Net system.
    3. Look for the code that lets VB.Net identify the layers of line in the imported AutoCad project.
    4. Add a function that when the user hovers its mouse to the layers of line it will highlight that layers of line
    5. Identify if that layers of line (AKA circuit per panel) has a linked load description data, the next step will fall to one of the following conditions:
    *If the user does not add a load description data to that particular circuit per panel, the system should ask the user to input the necessary information so that we can linked them together.
    *If the user already added the load analysis data the system should linked them together, allowing the user to identify what load description data corresponds to the circuit per panel that the user hover its mouse.


    I'am now stuck at step 2, which is importing an existing project to the vb.net system. Currently looking for answers here https://forums.autodesk.com/t5/net/i...4725623#M38494
    Last edited by cary1234; Jan 14th, 2019 at 07:14 PM.

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,018

    Re: Integrating AutoCad to VB.Net

    Quote Originally Posted by cary1234 View Post
    2. Look for ways to import an existing AutoCad project to the VB.Net system.
    You're looking at it backwards. You're not importing anything into your VB.NET application. AutoCAD is still going to do what AutoCAD does. The difference will be that your application is sending the instructions to AutoCAD to tell it what to do rather than a user with a keyboard and mouse. You first need to determine what action(s) you would perform if you were sitting at a computer using AutoCAD normally, then check the AutoCAD API documentation to see what objects(s) and member(s) you need to use in your VB.NET code to tell AutoCAD to perform the same action. For example, just as you would open a drawing file in AutoCAD using an Open item on a File menu or the like, so there will ne an OpenDrawingFile method or the like in the AutoCAD .NET API. When you call that method, you're not opening a file in your VB.NET app. You're telling AutoCAD to open a file and it will do so in exactly the same way as if you used the menu system in AutoCAD.

  6. #6
    Hyperactive Member
    Join Date
    Jun 2018
    Posts
    287

    Re: Integrating AutoCad to VB.Net

    Cary,

    Yes you should try to do this within Acad as the others have said.

    If one must one can use DXF (Drawing Exchange Format) ascii file format (ie in acad its DXFOUT command) to import/export drawing data into VB.

    This can be done fairly easily if all you want is simple line, circle, text, and layer info. I am not sure about the info you want. It should be possible.

    Here are some docs set on an example for simple input files. In DXF you skip everything you don't know how to read. That is how DXF works. If the code does not understand something it is not read the data. ie you look for info tables and read that. It appears the example dxf code in the docs reads only the line objects from the DXF file.

    So you save the drawing as dxf from acad, then process, then save as dxf, then read the dxf into the acad dwg drawing. Perhaps you can find a simple api to do the dxf in and out from vb.

    Here are the Acad docs for DXF.

    Look under "writing dxf programs" for sample Basic code (not exactly vb.net code).

    PS This allows you to read the coordinate geometry data. Then you will have to write Vb code to draw the drawing and do the operations you want. Or maybe you don't need to draw the drawing in vb.net??? Just show the result? And or modify the data and write the result into the drawing using DXF.

    For example here is a line from (0,0) to (48,48) inches in a DXF file:

    SECTION
    2
    ENTITIES
    0
    LINE
    8
    tommytwotrain example layer
    6
    CONTINUOUS
    10
    0.0
    20
    0.0
    30
    0.0
    11
    48
    21
    48
    31
    0.0
    0
    ENDSEC
    0


    In fact DXF is much like XML !
    Last edited by tommytwotrain; Jan 15th, 2019 at 04:41 AM.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Posts
    253

    Re: Integrating AutoCad to VB.Net

    Thank you so much jmcilhinney for pointing out that I' am looking at it backwards. Now I understand the concept more.

    Thank you also tommytwotrain for the help, I am now studying the DXF and so far I'am able to generate basic lines easily

    Name:  1.jpg
Views: 135
Size:  21.5 KB

    When I try to insert the actual project of autocad that I'am working hers the output

    Name:  2.jpg
Views: 137
Size:  17.9 KB

    Those are just my first trial, I'll surely study more regarding DXF, thanks for pointing that out.

  8. #8
    Addicted Member
    Join Date
    Jan 2016
    Posts
    153

    Re: Integrating AutoCad to VB.Net

    why are you (what looks like) trying to re-create "AutoCAD" in your own form window? just use AutoCAD. have it check the drawing and feed you the information you need. Why go through the trouble of re-making what already exists?

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Posts
    253

    Re: Integrating AutoCad to VB.Net

    Thanks CWITT, regarding your question

    The steps in the system that I want to create are the following:

    1. Integrate AutoCad to VB.Net.
    2. Look for ways to import an existing AutoCad project to the VB.Net system.
    3. Look for the code that lets VB.Net identify the layers of line in the imported AutoCad project.
    4. Add a function that when the user hovers its mouse to the layers of line it will highlight that layers of line
    5. Identify if that layers of line (AKA circuit per panel) has a linked load description data, the next step will fall to one of the following conditions:
    *If the user does not add a load description data to that particular circuit per panel, the system should ask the user to input the necessary information so that we can linked them together.
    *If the user already added the load analysis data the system should linked them together, allowing the user to identify what load description data corresponds to the circuit per panel that the user hover its mouse.


    In the step 5 I want to highlight the AutoCAD objects and also highlight the load description that pertains to that circuits in autocad. Can I still do this just by using the DXF?

  10. #10
    Addicted Member
    Join Date
    Jan 2016
    Posts
    153

    Re: Integrating AutoCad to VB.Net

    As has been said before you do NOT bring the drawing into .Net.

    IMO, you need to forget you ever heard of DXF. Given what your goals are, you should be creating your entire program INSIDE AutoCAD (you save the program as a dll and load it into CAD and run it there). from that vantage point you can do all the checking and linking you want (and have it saved in the drawing.. there are several methods for saving custom data inside a DWG file).

    Edit:
    https://forums.autodesk.com/t5/net/bd-p/152

    that forum is gold for programing in AutoCAD.

    also this..
    http://www.vbcad.com/vbcadbooks.htm
    Last edited by CWITT; Jan 15th, 2019 at 07:15 PM.

  11. #11
    Hyperactive Member
    Join Date
    Jun 2018
    Posts
    287

    Re: Integrating AutoCad to VB.Net

    Cary,

    RE Your DXF drawing.... Hey Very Nice!! LOL!


    "In the step 5 I want to highlight the AutoCAD objects and also highlight the load description that pertains to that circuits in autocad. Can I still do this just by using the DXF? "


    No. Why would it do that? DXF is just a file format and a file of data. So you you are in vb then you have to write the code to find the object clicked on and make the this and that...

    So that is the thing. In acad you have a findobject from click function or something. In vb we have point in rect and stuff like that.

    If all you want to do is add up how many feet of no. 9 bars in table two then ...

    But you can see it quickly turns into you create a cad program with what you last described.

    So it depends. Do you have a year? A week? Are you a student? A junior engr and on and on.

    But DXF is old and limited. It has limited use and etc. I just showed it because it is a way to easily more or less get the acad drawing data into vb (which you showed). Of course that's all debatable.

    I assume you have already spent time in acad? Lets see you do something from vb.net using acad.api now.

    PS You could do those things maybe with the DXF data in vb but you have to write the code to loop through the lines in vb and check the mouse click and etc where in acad there may be an easier way.

    Plus if you want to put it into acad then it will just be better to leave it there?

    Lets see you draw a rect in an acad drawing from vb now?



    Last edited by tommytwotrain; Jan 15th, 2019 at 08:12 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width