Set import units for DXF as sketch block

Use this space to ask how to do whatever you're trying to use SolidWorks to do.
User avatar
Rob
Posts: 128
Joined: Mon Mar 08, 2021 3:46 pm
Answers: 2
Location: Mighty Glossop, UK
x 787
x 208
Contact:

Set import units for DXF as sketch block

Unread post by Rob »

Hi Guys

I've been experimenting over the weekend and discovered that you can drag a dxf into a sketch and it becomes a sketch block.

Pretty cool stuff, but there is no import options dialog to specify the units and somehow the dimensions are coming in as inches, so my 100mm edge becomes 2540mm.

My part templates are all in mm.
image.png

I can fix this by applying a scale parameter in the block properties but it would be nice to make it just work.
image.png
image.png (9.78 KiB) Viewed 777 times

I checked out the help but ominously it states
The DXF/DWG Import Wizard appears during most import operations.

Not really relevant but I am using netDxf to create dxf's and then importing them into SW.

I have tried changing the dxf header variables but it didn't make any difference.

Code: Select all


            HeaderVariables headerVariables = new ();

            headerVariables.AcadVer = DxfVersion.AutoCad2013;
            headerVariables.LUnits = netDxf.Units.LinearUnitType.Decimal;
            headerVariables.InsUnits = netDxf.Units.DrawingUnits.Millimeters;
            headerVariables.AddCustomVariable(new ("$MEASUREMENT", 70, (short)1)); // Metric

            var doc = new DxfDocument(headerVariables);

            var exDims = new ExDims(100, 150);

            EntityObject entity = new Polyline(vertexes: CreateVectors(exDims.Coordinates()), isClosed: true);

            doc.AddEntity(entity);

            IMargin margin = new EqualMargin(10);

            entity = new Polyline(CreateVectors(margin.Coordinates(exDims)), true);
            doc.AddEntity(entity);

            doc.Save("C:\\temp\\test.dxf");

            

I have also tried general import setting using document specified unit
image.png

Anyone know if this is possible?

Just to restate I'm not looking to import as a sketch, but directly as a sketch block.

Thanks for looking
User avatar
Rob
Posts: 128
Joined: Mon Mar 08, 2021 3:46 pm
Answers: 2
Location: Mighty Glossop, UK
x 787
x 208
Contact:

Re: Set import units for DXF as sketch block

Unread post by Rob »

I tried this with a dxf I exported from SW and it worked, so guess the problem lies with my usage of the netDxf library
Post Reply