File tree Expand file tree Collapse file tree 3 files changed +23
-17
lines changed Expand file tree Collapse file tree 3 files changed +23
-17
lines changed Original file line number Diff line number Diff line change @@ -68,15 +68,17 @@ public void setOriginHatch()
6868 using ( Transaction tr2 = doc . TransactionManager . StartTransaction ( ) )
6969 {
7070 Entity ent = ( Entity ) tr2 . GetObject ( mHatchId , OpenMode . ForWrite ) ;
71- if ( ent != null )
7271 {
73- Hatch nHatch = ent as Hatch ;
74- String hatchName = nHatch . PatternName ;
72+ Hatch ? nHatch = ent as Hatch ;
73+ string ? hatchName = nHatch ? . PatternName ;
7574 Point2d setOrigin = new Point2d ( 6.698 , 2.78 ) ;
76- nHatch . Origin = setOrigin ;
77- nHatch . SetHatchPattern ( HatchPatternType . PreDefined , hatchName ) ;
78- nHatch . EvaluateHatch ( true ) ;
79- nHatch . Draw ( ) ;
75+ if ( nHatch != null )
76+ {
77+ nHatch . Origin = setOrigin ;
78+ nHatch . SetHatchPattern ( HatchPatternType . PreDefined , hatchName ) ;
79+ nHatch . EvaluateHatch ( true ) ;
80+ nHatch . Draw ( ) ;
81+ }
8082 }
8183
8284 tr2 . Commit ( ) ;
Original file line number Diff line number Diff line change @@ -19,14 +19,18 @@ public void cmdCreateCricle()
1919 using ( var tr = db . TransactionManager . StartTransaction ( ) )
2020 {
2121 var bt = tr . GetObject ( db . BlockTableId , OpenMode . ForRead ) as BlockTable ;
22- var ms = tr . GetObject ( bt [ BlockTableRecord . ModelSpace ] , OpenMode . ForWrite ) as BlockTableRecord ;
23- var circle = new Autodesk . AutoCAD . DatabaseServices . Circle ( ) ;
24- Random ran = new Random ( ) ;
25- int c = ran . Next ( 0 , 100 ) ;
26- circle . Center = new Point3d ( 0 , 10 , 0 ) ;
27- circle . Radius = c ;
28- ms . AppendEntity ( circle ) ;
29- tr . AddNewlyCreatedDBObject ( circle , true ) ;
22+ if ( bt != null )
23+ {
24+ var ms = tr . GetObject ( bt [ BlockTableRecord . ModelSpace ] , OpenMode . ForWrite ) as BlockTableRecord ;
25+ var circle = new Autodesk . AutoCAD . DatabaseServices . Circle ( ) ;
26+ Random ran = new Random ( ) ;
27+ int c = ran . Next ( 0 , 100 ) ;
28+ circle . Center = new Point3d ( 0 , 10 , 0 ) ;
29+ circle . Radius = c ;
30+ ms ? . AppendEntity ( circle ) ;
31+ tr . AddNewlyCreatedDBObject ( circle , true ) ;
32+ }
33+
3034 tr . Commit ( ) ;
3135
3236 }
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ public void FindCmdDuplicatesCmd()
5353
5454 {
5555 string asmPath = SelectAssembly ( ) ;
56- if ( asmPath == null ) return ;
56+ if ( string . IsNullOrEmpty ( asmPath ) ) return ;
5757 FindCmdDuplicates ( asmPath ) ;
5858 }
5959
@@ -103,7 +103,7 @@ private string SelectAssembly()
103103 }
104104
105105
106- return null ;
106+ return String . Empty ;
107107 }
108108
109109
You can’t perform that action at this time.
0 commit comments