Read multiple files to one model

1 2    next >
Clay
10/9/2007 8:55 AM

Hi everybody

I need a CAD-Lib to load multiple Dxf-Files to one model, add something (circles, lines) by hand and by code and then save this hole thing as a new Dxf-File. Is this possbile with this CadLib?

I tried a little bit with the examples and figured out how to load one Dxf-File, add something by code and save this. But how to load multiple files? And is it possible to add (ex. a circle) by hand like in a professional CAD-Software?

I hope that CadLib can do all these things, so I can buy it and save much time and money :-)

thanks in advance
Clay

Wout
10/9/2007 10:37 AM

Hi Clay,

Some of your wishes can be done using CadLib, with some special care:

There is no 'Merge' function that merges DxfModel objects, but you can Clone individual entities from one DxfModel to another. See method DxfHandledObject.Clone(DxfModel targetModel, ReferenceResolutionType referenceResolutionType). DxfHandledObject is the super class for all data objects in CadLib. A brute force Merge method wouldn't work, because there will always be items that are shared between models, like layers and line types and such, and you can't brute force your way in selecting which items are supposed to override the other. So some trade offs probably have to be made in this area, which only the user of the library can do.

I did start a while ago on making mouse interactors for creating entities, but so far there is only one (for polylines, see the WW.Cad.Actions namespace), because a customer requested it. Possibly I can write some more though, which ones would you need?

Thanks,

Wout

Clay
10/9/2007 10:54 AM

Hi Wout,

thank you for your answer. It seems that I have to read first something about CAD, dxf, and so on, to understand how a dxf file works. Its the first time I work with Dxf-Files.

a short explanation what I have to do:
I have to evaluate a CAD-Lib for a Software that we plan to develope. The main goal of the software will be to drag some dxf-files to a 'container', add some handmade cad-parts (circles, etc) and save this to a new dxf-file which can be produced on a CNC-Machine.
Do you think it will be possible with the clone-method to do this?

best regards

Wout
10/9/2007 11:29 AM

Hi Clay,

Yes, that should be perfectly possible. For drawing the circles some extra work is needed, as mentioned before.

Let me know how it all goes!

Wout

jingsongtang
10/9/2007 5:59 PM

Hi Wout:

I have been evaluating CADLib. Among tens of the tools I evaluated, seems that CADLib is the one that meets our needs. I am currently trying to put together a prototype. if it confirms that CADLIB can do what we want, we are going to use it in our product.

As to the interactor, I would like one for dimensioning. The idea is that once our application build the basic model, the user could measure any dimension he needs. It might be hard for us to anticipate every dimension the user would be interested in, and my intuition is that it is not easy to put the dimension in the right spot programmatically. If the user can do it interactively, that might make our life easier.

Other feature I would like to see in CADLib is model transform. I read a few comments you had about model transform, and understand that it is not an easy task, but it would add a lot of values to us.

One more thing, I tried inserting a block, then scaled it by 3 times. When I checked the lines in block, their start and end points were still the same as those before the scaling. For example, a line was originally from (0,0,0) to (1, 0, 0), after I scaled it by three times, the start and end points were still (0,0,0) and (1, 0, 0), while the line was three times longer. What I expected were (0,0,0) and (3, 0 , 0) Is this the expected behavior?

Wout
10/9/2007 6:11 PM

Hi Clay,

Thank you for the feedback. Indeed setting any transform only affects the way entities are displayed, so it does not change the original coordinates. Typically this is desired behavior, because it enables you to insert the same block multiple times in a drawing and transform each insert differently, without perturbing the original block.

Adding interactors for dimensions shouldn't be too bad I suspect, I'll give it a shot the coming weekend. Would the DxfDimension.Linear be the one you'd need? There are about 7 different dimension flavors, see the DxfDimension sub classes.

Thanks!

Wout

jingsongtang
10/10/2007 4:48 AM

DxfDimension.Linear would be the most important one.

Wout
10/10/2007 11:54 AM

Oh, I just noticed you're not clay! Apologies for not noticing!

Wout

Clay
10/11/2007 7:57 AM

Hi Wout

Yes, jingsongtang's post in this thread was a little bit confusing :-)

I have a problem with the clone method. Nothing happens when I try to clone a polyline from one model to another. I think I haven't understood how the cloning works. Here's my code:

C# Code:
   DxfModel sourcemodel = DxfReader.ReadDxf(@'c:\temp\source.dxf');
   IEnumerator<DxfEntity> it = sourcemodel.Entities.GetEnumerator();
   while (it.MoveNext())
   {
      DxfEntity entity = it.Current;
      if (entity.EntityType.Equals('POLYLINE'))
      {
         if (!dxfControl.Model.Layers.Contains(entity.Layer.Name))
         {
              DxfLayer layer = new DxfLayer(entity.Layer.Name);
              dxfControl.Model.Layers.Add(layer);
         }
         entity.Clone(dxfControl.Model, ReferenceResolutionType.FailOnMissing);
       }
   }

Any idea? new layers are created and the code line with 'entity.Clone(...)' is reached.
I think if this point works, the CADLib will be a part of our new software :-)

best regards
Clay

Wout
10/11/2007 11:00 AM

Hi Clay,

Can you e-mail me your solution and the sample DXF file? That code looks fine, though it can be a bit more refined.

C# Code:
   DxfModel sourcemodel = DxfReader.ReadDxf(@'c:\temp\source.dxf');
     foreach (DxfEntity entity in sourceModel.Entities) {
      DxfPolyline polyline = entity as DxfPolyline;
      if (polyline != null) {
         // This will also clone referenced objects like layers, line types and such
         // if missing.                 
         polyline.Clone(dxfControl.Model, ReferenceResolutionType.CloneMissing);
       }
   }

Wout

1 2    next >