개정판 ec5dc86d
Save Block as DWG For Auxiliary Graphic
Change-Id: I5433ae6fdecf4697ff6232892fe6473ee7f5acda
DTI_PID/OdReadExMgd/OdReadExMgd.cs | ||
---|---|---|
3398 | 3398 |
|
3399 | 3399 |
if (ent is BlockReference) |
3400 | 3400 |
{ |
3401 |
|
|
3401 | 3402 |
changeColorBlocks(tr, (BlockReference)ent); |
3402 | 3403 |
} |
3403 | 3404 |
} |
... | ... | |
3539 | 3540 |
} |
3540 | 3541 |
|
3541 | 3542 |
/************************************************************************/ |
3543 |
/* Save Block as DWG For Auxiliary Graphic */ |
|
3544 |
/************************************************************************/ |
|
3545 |
public void ExportGraphicBlocks(Database pDb, string savePath) |
|
3546 |
{ |
|
3547 |
try |
|
3548 |
{ |
|
3549 |
using (BlockTable pTable = (BlockTable)pDb.BlockTableId.Open(OpenMode.ForRead)) |
|
3550 |
{ |
|
3551 |
using (BlockTableRecord pBlock = (BlockTableRecord)pTable[BlockTableRecord.ModelSpace].Open(OpenMode.ForRead, false, true)) |
|
3552 |
{ |
|
3553 |
foreach (ObjectId entid in pBlock) |
|
3554 |
{ |
|
3555 |
using (Entity pEnt = (Entity)entid.Open(OpenMode.ForRead, false, true)) |
|
3556 |
{ |
|
3557 |
if (pEnt.GetRXClass().Name != "AcDbBlockReference") continue; |
|
3558 |
BlockReference blockRef = (BlockReference)pEnt; |
|
3559 |
if (!blockRef.Name.ToUpper().StartsWith("GRAPHIC+")) |
|
3560 |
continue; |
|
3561 |
|
|
3562 |
ObjectIdCollection objIdCol = new ObjectIdCollection(); |
|
3563 |
objIdCol.Add(blockRef.ObjectId); |
|
3564 |
if (objIdCol.Count == 0) continue; |
|
3565 |
|
|
3566 |
string filePath = string.Format("{0}.dwg", blockRef.Name); |
|
3567 |
string directory = Path.GetDirectoryName(savePath); |
|
3568 |
directory = directory.ToLower().Replace("drawings", "graphic"); |
|
3569 |
if (!Directory.Exists(directory)) |
|
3570 |
{ |
|
3571 |
Directory.CreateDirectory(directory); |
|
3572 |
} |
|
3573 |
filePath = Path.Combine(directory, filePath); |
|
3574 |
|
|
3575 |
using (Database newDb = new Database(true, false)) |
|
3576 |
{ |
|
3577 |
pDb.Wblock(newDb, objIdCol, Point3d.Origin, DuplicateRecordCloning.Ignore); |
|
3578 |
newDb.UpdateExt(true); |
|
3579 |
newDb.SaveAs(filePath, DwgVersion.Newest); |
|
3580 |
} |
|
3581 |
|
|
3582 |
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo(); |
|
3583 |
procStartInfo.FileName = @"C:\Program Files (x86)\SmartSketch\Program\Rad2d\bin\Dwg2Igr.exe"; |
|
3584 |
procStartInfo.RedirectStandardOutput = true; |
|
3585 |
procStartInfo.RedirectStandardInput = true; |
|
3586 |
procStartInfo.RedirectStandardError = true; |
|
3587 |
procStartInfo.UseShellExecute = false; |
|
3588 |
procStartInfo.CreateNoWindow = false; |
|
3589 |
procStartInfo.Arguments = filePath.Replace(" ", "^"); |
|
3590 |
|
|
3591 |
using (System.Diagnostics.Process proc = new System.Diagnostics.Process()) |
|
3592 |
{ |
|
3593 |
proc.StartInfo = procStartInfo; |
|
3594 |
proc.Start(); |
|
3595 |
proc.StandardInput.Close(); |
|
3596 |
proc.WaitForExit(); |
|
3597 |
|
|
3598 |
switch (proc.ExitCode) |
|
3599 |
{ |
|
3600 |
case -1: |
|
3601 |
Console.WriteLine("[{0}] path does not exist or there is no file", filePath); |
|
3602 |
break; |
|
3603 |
case 0: |
|
3604 |
Console.WriteLine("[{0}] File conversion error", filePath.Replace(".dwg", ".igr")); |
|
3605 |
break; |
|
3606 |
case 1: |
|
3607 |
Console.WriteLine("[{0}] File conversion success", filePath.Replace(".dwg", ".igr")); |
|
3608 |
break; |
|
3609 |
default: |
|
3610 |
break; |
|
3611 |
} |
|
3612 |
} |
|
3613 |
} |
|
3614 |
} |
|
3615 |
} |
|
3616 |
} |
|
3617 |
} |
|
3618 |
catch (System.Exception ex) |
|
3619 |
{ |
|
3620 |
} |
|
3621 |
} |
|
3622 |
/************************************************************************/ |
|
3542 | 3623 |
/* Dump the BlockTable */ |
3543 | 3624 |
/************************************************************************/ |
3544 | 3625 |
public void dumpBlocks(Database pDb, int indent, XmlNode node) |
... | ... | |
4769 | 4850 |
{ |
4770 | 4851 |
dumper.ExportPNG(pDb, args[0]); |
4771 | 4852 |
dumper.ExportPDF(pDb, args[0]); |
4853 |
dumper.ExportGraphicBlocks(pDb, args[0]); |
|
4772 | 4854 |
} |
4773 | 4855 |
|
4774 | 4856 |
dumper.dump(pDb, 0, Program.xml.DocumentElement); |
내보내기 Unified diff