TheSwamp
Code Red => .NET => Topic started by: It's Alive! on November 03, 2007, 08:55:51 AM
-
DevTV: Introductory recordings on Autodesk APIs
http://through-the-interface.typepad.com/through_the_interface/2007/11/devtv-introduct.html
-
ta !
-
wow, check out the one by Fenton. I had no idea we could do all that, the can of worms is open now!
-
........ the can of worms is open now!
Sorry James ,you lost me ?
-
Hi there folks, I'm new here so I thought I'd my $0.02 to this post: -
EDIT: Me again :-o
After further experimentation it would appear the "keywordoptions" I mentioned previously are very case-sensitive. :oops:
-
Hi there folks, I'm new here so I thought I'd my $0.02 to this post: -
EDIT: Me again :-o
After further experimentation it would appear the "keywordoptions" I mentioned previously are very case-sensitive. :oops:
Welcome vegbruiser. C# or VB ?
-
VB.
-
Glenn . We have another that’s needs converting, Do your stuff! :police:
-
So much for "Conversion from Vb to C# is Simple .. " [*cough]
.. bloody mickeyMouse languages without curley braces twist my nickers something awefull ..
Converted with SharpDevelop 2.2
Warning 1 Missing XML comment for publicly visible type or member 'UserControl1' ....\UserControl1.Designer.cs 2 15 DevTvIntro.Converted
Warning 2 Missing XML comment for publicly visible type or member 'UserControl1.Dispose(bool)' ....\UserControl1.Designer.cs 7 26 DevTvIntro.Converted
Warning 3 Missing XML comment for publicly visible type or member 'adskClass' ....\Class.cs 29 14 DevTvIntro.Converted
Error 4 The name 'Constants' does not exist in the current context ....\Class.cs 40 24 DevTvIntro.Converted
Error 5 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 93 32 DevTvIntro.Converted
Error 6 Cannot convert method group 'StartTransaction' to non-delegate type 'Autodesk.AutoCAD.DatabaseServices.Transaction'. Did you intend to invoke the method? ....\Class.cs 132 27 DevTvIntro.Converted
Error 7 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.BlockTable'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 142 32 DevTvIntro.Converted
Error 8 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 185 36 DevTvIntro.Converted
Warning 9 Missing XML comment for publicly visible type or member 'adskClass.myPaletteSet' ....\Class.cs 215 45 DevTvIntro.Converted
Warning 10 Missing XML comment for publicly visible type or member 'adskClass.myPalette' ....\Class.cs 217 22 DevTvIntro.Converted
Error 11 The type or namespace name 'Guid' could not be found (are you missing a using directive or an assembly reference?) ....\Class.cs 228 77 DevTvIntro.Converted
Error 12 The best overloaded method match for 'Autodesk.AutoCAD.Windows.PaletteSet.PaletteSet(string, System.Guid)' has some invalid arguments ....\Class.cs 228 19 DevTvIntro.Converted
Error 13 Argument '2': cannot convert from 'Guid' to 'System.Guid' ....\Class.cs 228 73 DevTvIntro.Converted
Error 14 The name 'Constants' does not exist in the current context ....\Class.cs 251 20 DevTvIntro.Converted
Error 15 The type or namespace name 'Forms' could not be found (are you missing a using directive or an assembly reference?) ....\Class.cs 282 13 DevTvIntro.Converted
Error 16 The type or namespace name 'Forms' could not be found (are you missing a using directive or an assembly reference?) ....\Class.cs 304 3 DevTvIntro.Converted
Error 17 The type or namespace name 'Forms' could not be found (are you missing a using directive or an assembly reference?) ....\Class.cs 314 12 DevTvIntro.Converted
Error 18 Cannot convert method group 'StartTransaction' to non-delegate type 'Autodesk.AutoCAD.DatabaseServices.Transaction'. Did you intend to invoke the method? ....\Class.cs 337 24 DevTvIntro.Converted
Error 19 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.Entity'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 341 18 DevTvIntro.Converted
Error 20 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.DBDictionary'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 353 34 DevTvIntro.Converted
Error 21 The name 'ControlChars' does not exist in the current context ....\Class.cs 362 22 DevTvIntro.Converted
Error 22 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.Xrecord'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 366 18 DevTvIntro.Converted
Error 23 The name 'ControlChars' does not exist in the current context ....\Class.cs 369 23 DevTvIntro.Converted
Error 24 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.TypedValue.TypedValue(int, object)' has some invalid arguments ....\Class.cs 380 43 DevTvIntro.Converted
Error 25 Argument '1': cannot convert from 'Autodesk.AutoCAD.DatabaseServices.DxfCode' to 'int' ....\Class.cs 380 58 DevTvIntro.Converted
Error 26 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.TypedValue.TypedValue(int, object)' has some invalid arguments ....\Class.cs 380 77 DevTvIntro.Converted
Error 27 Argument '1': cannot convert from 'Autodesk.AutoCAD.DatabaseServices.DxfCode' to 'int' ....\Class.cs 380 92 DevTvIntro.Converted
Error 28 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.TypedValue.TypedValue(int, object)' has some invalid arguments ....\Class.cs 380 122 DevTvIntro.Converted
Error 29 Argument '1': cannot convert from 'Autodesk.AutoCAD.DatabaseServices.DxfCode' to 'int' ....\Class.cs 380 137 DevTvIntro.Converted
Error 30 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.TypedValue.TypedValue(int, object)' has some invalid arguments ....\Class.cs 380 158 DevTvIntro.Converted
Error 31 Argument '1': cannot convert from 'Autodesk.AutoCAD.DatabaseServices.DxfCode' to 'int' ....\Class.cs 380 173 DevTvIntro.Converted
Error 32 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.TypedValue.TypedValue(int, object)' has some invalid arguments ....\Class.cs 380 195 DevTvIntro.Converted
Error 33 Argument '1': cannot convert from 'Autodesk.AutoCAD.DatabaseServices.DxfCode' to 'int' ....\Class.cs 380 210 DevTvIntro.Converted
Error 34 The type or namespace name 'Forms' could not be found (are you missing a using directive or an assembly reference?) ....\Class.cs 394 16 DevTvIntro.Converted
Error 35 The type or namespace name 'Forms' could not be found (are you missing a using directive or an assembly reference?) ....\Class.cs 399 9 DevTvIntro.Converted
Error 36 Cannot convert method group 'StartTransaction' to non-delegate type 'Autodesk.AutoCAD.DatabaseServices.Transaction'. Did you intend to invoke the method? ....\Class.cs 437 23 DevTvIntro.Converted
Error 37 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.DBDictionary'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 441 23 DevTvIntro.Converted
Error 38 The name 'ControlChars' does not exist in the current context ....\Class.cs 450 21 DevTvIntro.Converted
Error 39 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.Xrecord'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 454 17 DevTvIntro.Converted
Error 40 The name 'ControlChars' does not exist in the current context ....\Class.cs 457 22 DevTvIntro.Converted
Error 41 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.TypedValue.TypedValue(int, object)' has some invalid arguments ....\Class.cs 468 42 DevTvIntro.Converted
Error 42 Argument '1': cannot convert from 'Autodesk.AutoCAD.DatabaseServices.DxfCode' to 'int' ....\Class.cs 468 57 DevTvIntro.Converted
Error 43 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.TypedValue.TypedValue(int, object)' has some invalid arguments ....\Class.cs 468 76 DevTvIntro.Converted
Error 44 Argument '1': cannot convert from 'Autodesk.AutoCAD.DatabaseServices.DxfCode' to 'int' ....\Class.cs 468 91 DevTvIntro.Converted
Error 45 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.TypedValue.TypedValue(int, object)' has some invalid arguments ....\Class.cs 468 134 DevTvIntro.Converted
Error 46 Argument '1': cannot convert from 'Autodesk.AutoCAD.DatabaseServices.DxfCode' to 'int' ....\Class.cs 468 149 DevTvIntro.Converted
Error 47 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.TypedValue.TypedValue(int, object)' has some invalid arguments ....\Class.cs 468 170 DevTvIntro.Converted
Error 48 Argument '1': cannot convert from 'Autodesk.AutoCAD.DatabaseServices.DxfCode' to 'int' ....\Class.cs 468 185 DevTvIntro.Converted
Error 49 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.TypedValue.TypedValue(int, object)' has some invalid arguments ....\Class.cs 468 207 DevTvIntro.Converted
Error 50 Argument '1': cannot convert from 'Autodesk.AutoCAD.DatabaseServices.DxfCode' to 'int' ....\Class.cs 468 222 DevTvIntro.Converted
Error 51 Cannot implicitly convert type 'int' to 'bool' ....\Class.cs 511 8 DevTvIntro.Converted
Error 52 Cannot convert method group 'StartTransaction' to non-delegate type 'Autodesk.AutoCAD.DatabaseServices.Transaction'. Did you intend to invoke the method? ....\Class.cs 515 24 DevTvIntro.Converted
Error 53 'fullEntPath' is a 'variable' but is used like a 'method' ....\Class.cs 519 34 DevTvIntro.Converted
Error 54 The name 'Drawing' does not exist in the current context ....\Class.cs 524 90 DevTvIntro.Converted
Error 55 The name 'Drawing' does not exist in the current context ....\Class.cs 525 87 DevTvIntro.Converted
Error 56 The type or namespace name 'Forms' could not be found (are you missing a using directive or an assembly reference?) ....\Class.cs 530 14 DevTvIntro.Converted
Error 57 Cannot implicitly convert type 'Autodesk.AutoCAD.EditorInput.PointHistoryBits' to 'bool' ....\Class.cs 570 8 DevTvIntro.Converted
Error 58 Cannot implicitly convert type 'int' to 'bool' ....\Class.cs 630 8 DevTvIntro.Converted
Error 59 Cannot convert method group 'StartTransaction' to non-delegate type 'Autodesk.AutoCAD.DatabaseServices.Transaction'. Did you intend to invoke the method? ....\Class.cs 634 24 DevTvIntro.Converted
Error 60 'fullEntPath' is a 'variable' but is used like a 'method' ....\Class.cs 638 33 DevTvIntro.Converted
Error 61 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.DBDictionary'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 645 35 DevTvIntro.Converted
Error 62 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.Xrecord'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 654 18 DevTvIntro.Converted
Error 63 Operator '==' cannot be applied to operands of type 'short' and 'Autodesk.AutoCAD.DatabaseServices.DxfCode' ....\Class.cs 658 12 DevTvIntro.Converted
Error 64 The best overloaded method match for 'Autodesk.AutoCAD.DatabaseServices.Curve.GetPointAtDist(double)' has some invalid arguments ....\Class.cs 663 22 DevTvIntro.Converted
Error 65 Argument '1': cannot convert from 'object' to 'double' ....\Class.cs 663 41 DevTvIntro.Converted
Error 66 Cannot convert method group 'StartTransaction' to non-delegate type 'Autodesk.AutoCAD.DatabaseServices.Transaction'. Did you intend to invoke the method? ....\Class.cs 852 23 DevTvIntro.Converted
Error 67 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord'. An explicit conversion exists (are you missing a cast?) ....\Class.cs 856 36 DevTvIntro.Converted
Warning 68 Missing XML comment for publicly visible type or member 'adskClass.MyCircleJig' ....\Class.cs 705 15 DevTvIntro.Converted
Error 69 A local variable named 'jigPromptResult' is already defined in this scope ....\Class.cs 768 25 DevTvIntro.Converted
Error 70 Cannot implicitly convert type 'Autodesk.AutoCAD.EditorInput.PromptDoubleResult' to 'Autodesk.AutoCAD.EditorInput.PromptPointResult' ....\Class.cs 768 43 DevTvIntro.Converted
Error 71 Cannot implicitly convert type 'Autodesk.AutoCAD.Geometry.Point3d' to 'double' ....\Class.cs 774 16 DevTvIntro.Converted
Error 72 'adskClass.MyCircleJig.Update()': not all code paths return a value ....\Class.cs 799 27 DevTvIntro.Converted
Warning 73 Missing XML comment for publicly visible type or member 'adskClass.MyCircleJig.CurrentInput' ....\Class.cs 714 14 DevTvIntro.Converted
Warning 74 '42016' is not a valid warning number DevTvIntro.Converted
-
So much for "Conversion from Vb to C# is Simple .. " [*cough]
.. bloody mickeyMouse languages without curley braces twist my nickers something awefull ..
Poorly written converter or original source code? Or both? Personally I enjoy the idiosyncrasies of many languages, even the, errrm basic derivatives.
Edit: That does look awful tho.
-
I'm going back and starting over ..
Make sure the build in VB builds,netloads,works ..
.. then convert.
I've had this discussion previously and AutoDesk are quite happy to have everyone do their own conversions.
If you've tried to convert come of the SDK samples you'll know that some of the VB code does not convert.
-
I've tried again, and the errors/warnings continue.
I have no expectation that they would produce a recording for C#, but I'm astounded that AutoDesk have not provided a buildable C# solution.
Some of us don't have the time or inclination to learn the idiosyncracies of VB to the level required to make the translation.
This was s'posed to be a tutor, and ignoring half their potential audience doesn't seem to be aligned with their ascribed goal.
I've posted my thoughts on the blog, but doubt that a single voice will provide much incentive for remedial action on their part
... but Ive been wrong before :-)
added: The Revit Samples DO have both VB and CS code included ....
-
I share with you the
surprise and disappointment the powers that be failed to recognize the value and importance of providing all sample solutions in professionally written C#.
Edit: As shown. If you think about it they've never supplied professional level code / solutions. Not for LISP, not for VB, not for C#.
-
'never' is a big word .. but I'm disinclined to find a more suitable one ..
-
So you really can't look at VB.NET code and figure out how it should be done in C#?
-
Yes, It can be done ..
just a bit tricky when dealing with new concepts ..
and I don't have the time at the moment.
the real waste is that EVERYONE who wants to play with C# has to translate the code,
and that may proove a little difficult for newb's ...
Michael's use of the "P" word covers it nicely
.. professionally written C# (sample)....
-
Lucky I ignored eveyones advice on C#.
-
Anyone .. ?
I've wittled them down from 74 to 8 to 3
Some of the fixups may be less than perfect .. I'm a little brain dead :-)
Error 4 'fullEntPath' is a 'variable' but is used like a 'method'
... fixed
added:
and the 2 solutions ZIP FILES REMOVED :-
-
Any VB'rs know why these warnings would be suppressed ... ( I bite my tongue)
Warning 9 '42016' is not a valid warning number DevTvIntro
-
Kerry, please look at this one.. don't have much time to play as I have family visiting this week
-
Thanks Dan .. That seems to do the trick .... I couldn't see the trees for the forest !
Haven't tested all .. but it compiles, netloads and runs 'helloworld' :-)
I'm off to bed !
ta man !
-
I'm sorry I missed this Kerry. I didn't realise you were posting questions about the source code.
Are you still having trouble? If so, let me know and when I get back from breakfast (I'm in Singapore at the moment) I'll have a go at rewriting it for you and anybody else.
Cheers,
Glenn.
-
Hi Glenn,
sorry I missed the send -off !
The code Dan posted compiles, netloads and runs the simple stuff.
however,
After the Palette and addDBEvents Commands are run the TreeView is not visible on the pallete and subsequent drawing additions crash Acad.
I'm running in 3 directions at once , so if you have a moment between drinks and pestering hosties ...
-
I'm running in 3 directions at once
Neat trick ;)
I'll see what I can do...the view is quite exceptional...<wanders off>
-
I'm running in 3 directions at once
Kerry's a triathlete?
-
>> triathlete
:lmao:
-
Try this one, it seems the controls didn’t get translated correctly
-
quick Test ... seems to hold together Dan.
I'll have a look tonight. Thanks heaps!
-
I've just had one of 'those' thoughts ...
I wonder if doing the translation from VB to C# with Lutz Roeder's Reflector would be more efficient and accurate than using SharpDevelop ??
[addToListOfThingsToTest]
-
Do not know what of the demos you guys are using.... I download the first one on the list and opened on visual studio 2005, removed the debug to a2008, did the compile and open it using lutz reflector and getting something like:
[CommandMethod("addAnEnt")]
public void AddAnEnt()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptKeywordOptions getWhichEntityOptions = new PromptKeywordOptions("Which entity do you want to create? [Circle/Block] : ", "Circle Block");
PromptResult getWhichEntityResult = ed.GetKeywords(getWhichEntityOptions);
if (getWhichEntityResult.Status == PromptStatus.OK)
{
switch (getWhichEntityResult.StringResult)
{
case "Circle":
{
PromptPointOptions getPointOptions = new PromptPointOptions("Pick Center Point : ");
PromptPointResult getPointResult = ed.GetPoint(getPointOptions);
if (getPointResult.Status == PromptStatus.OK)
{
PromptDistanceOptions getRadiusOptions = new PromptDistanceOptions("Pick Radius : ");
getRadiusOptions.BasePoint = getPointResult.Value;
getRadiusOptions.UseBasePoint = true;
PromptDoubleResult getRadiusResult = ed.GetDistance(getRadiusOptions);
if (getRadiusResult.Status == PromptStatus.OK)
{
Database dwg = ed.Document.Database;
Transaction trans = dwg.TransactionManager.StartTransaction();
try
{
Circle circle = new Circle(getPointResult.Value, Vector3d.ZAxis, getRadiusResult.Value);
((BlockTableRecord) trans.GetObject(dwg.CurrentSpaceId, OpenMode.ForWrite)).AppendEntity(circle);
trans.AddNewlyCreatedDBObject(circle, true);
trans.Commit();
}
catch (Exception exception1)
{
ProjectData.SetProjectError(exception1);
Exception ex = exception1;
ed.WriteMessage("problem due to " + ex.Message);
ProjectData.ClearProjectError();
}
finally
{
trans.Dispose();
}
}
}
break;
}
case "Block":
{
PromptStringOptions blockNameOptions = new PromptStringOptions("Enter name of the Block to create : ");
blockNameOptions.AllowSpaces = false;
PromptResult blockNameResult = ed.GetString(blockNameOptions);
if (blockNameResult.Status == PromptStatus.OK)
{
Database dwg = ed.Document.Database;
Transaction trans = dwg.TransactionManager.StartTransaction();
try
{
BlockTableRecord newBlockDef = new BlockTableRecord();
newBlockDef.Name = blockNameResult.StringResult;
BlockTable blockTable = (BlockTable) trans.GetObject(dwg.BlockTableId, OpenMode.ForRead);
if (!blockTable.Has(blockNameResult.StringResult))
{
blockTable.UpgradeOpen();
blockTable.Add(newBlockDef);
trans.AddNewlyCreatedDBObject(newBlockDef, true);
}
Point3d VB$t_struct$S0 = new Point3d(0.0, 0.0, 0.0);
Circle circle1 = new Circle(VB$t_struct$S0, Vector3d.ZAxis, 10.0);
VB$t_struct$S0 = new Point3d(20.0, 10.0, 0.0);
Circle circle2 = new Circle(VB$t_struct$S0, Vector3d.ZAxis, 10.0);
VB$t_struct$S0 = new Point3d(40.0, 20.0, 0.0);
Circle circle3 = new Circle(VB$t_struct$S0, Vector3d.ZAxis, 10.0);
VB$t_struct$S0 = new Point3d(60.0, 30.0, 0.0);
Circle circle4 = new Circle(VB$t_struct$S0, Vector3d.ZAxis, 10.0);
VB$t_struct$S0 = new Point3d(80.0, 40.0, 0.0);
Circle circle5 = new Circle(VB$t_struct$S0, Vector3d.ZAxis, 10.0);
newBlockDef.AppendEntity(circle1);
newBlockDef.AppendEntity(circle2);
newBlockDef.AppendEntity(circle3);
newBlockDef.AppendEntity(circle4);
newBlockDef.AppendEntity(circle5);
trans.AddNewlyCreatedDBObject(circle1, true);
trans.AddNewlyCreatedDBObject(circle2, true);
trans.AddNewlyCreatedDBObject(circle3, true);
trans.AddNewlyCreatedDBObject(circle4, true);
trans.AddNewlyCreatedDBObject(circle5, true);
PromptPointOptions blockRefPointOptions = new PromptPointOptions("Pick insertion point of Block : ");
PromptPointResult blockRefPointResult = ed.GetPoint(blockRefPointOptions);
if (blockRefPointResult.Status != PromptStatus.OK)
{
trans.Dispose();
}
else
{
BlockReference blockRef = new BlockReference(blockRefPointResult.Value, newBlockDef.ObjectId);
((BlockTableRecord) trans.GetObject(dwg.CurrentSpaceId, OpenMode.ForWrite)).AppendEntity(blockRef);
trans.AddNewlyCreatedDBObject(blockRef, true);
trans.Commit();
}
}
catch (Exception exception2)
{
ProjectData.SetProjectError(exception2);
Exception ex = exception2;
ed.WriteMessage("a problem occured because " + ex.Message);
ProjectData.ClearProjectError();
}
finally
{
trans.Dispose();
}
}
break;
}
}
}
}
[CommandMethod("addData")]
public void addData()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityResult getEntityResult = ed.GetEntity("Pick an entity to add an Extension Dictionary to : ");
if (getEntityResult.Status == PromptStatus.OK)
{
Transaction trans = ed.Document.Database.TransactionManager.StartTransaction();
try
{
Entity ent = (Entity) trans.GetObject(getEntityResult.ObjectId, OpenMode.ForRead);
if (ent.ExtensionDictionary.IsNull)
{
ent.UpgradeOpen();
ent.CreateExtensionDictionary();
}
DBDictionary extensionDict = (DBDictionary) trans.GetObject(ent.ExtensionDictionary, OpenMode.ForRead);
try
{
ObjectId entryId = extensionDict.GetAt("MyData");
ed.WriteMessage("\nThis entity already has data...");
Xrecord myXrecord = (Xrecord) trans.GetObject(entryId, OpenMode.ForRead);
foreach (TypedValue value in myXrecord.Data)
{
ed.WriteMessage("\n" + value.TypeCode.ToString() + " . " + value.Value.ToString());
}
}
catch (Exception exception1)
{
ProjectData.SetProjectError(exception1);
extensionDict.UpgradeOpen();
Xrecord myXrecord = new Xrecord();
TypedValue[] VB$t_array$S0 = new TypedValue[5];
TypedValue VB$t_struct$S1 = new TypedValue(70, 1);
VB$t_array$S0[0] = VB$t_struct$S1;
TypedValue VB$t_struct$S2 = new TypedValue(1, "MyStockData");
VB$t_array$S0[1] = VB$t_struct$S2;
TypedValue VB$t_struct$S3 = new TypedValue(40, 51.9);
VB$t_array$S0[2] = VB$t_struct$S3;
TypedValue VB$t_struct$S4 = new TypedValue(40, 100.0);
VB$t_array$S0[3] = VB$t_struct$S4;
TypedValue VB$t_struct$S5 = new TypedValue(40, 320.6);
VB$t_array$S0[4] = VB$t_struct$S5;
ResultBuffer data = new ResultBuffer(VB$t_array$S0);
myXrecord.Data = data;
extensionDict.SetAt("MyData", myXrecord);
trans.AddNewlyCreatedDBObject(myXrecord, true);
if (this.myPalette != null)
{
try
{
foreach (TreeNode node in this.myPalette.TreeView1.Nodes)
{
if (Operators.ConditionalCompareObjectEqual(node.Tag, ent.ObjectId.ToString(), false))
{
TreeNode childNode = node.Nodes.Add("Extension Dictionary");
foreach (TypedValue value in myXrecord.Data)
{
childNode.Nodes.Add(value.ToString());
}
goto Label_0302;
}
}
}
finally
{
IEnumerator VB$t_ref$L1;
if (VB$t_ref$L1 is IDisposable)
{
(VB$t_ref$L1 as IDisposable).Dispose();
}
}
}
Label_0302:
ProjectData.ClearProjectError();
}
trans.Commit();
}
catch (Exception exception2)
{
ProjectData.SetProjectError(exception2);
Exception ex = exception2;
ed.WriteMessage("a problem occured because " + ex.Message);
ProjectData.ClearProjectError();
}
finally
{
trans.Dispose();
}
}
}
[CommandMethod("addDataToNOD")]
public void addDataToNOD()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Transaction trans = ed.Document.Database.TransactionManager.StartTransaction();
try
{
DBDictionary nod = (DBDictionary) trans.GetObject(ed.Document.Database.NamedObjectsDictionaryId, OpenMode.ForRead);
try
{
ObjectId entryId = nod.GetAt("MyData");
ed.WriteMessage("\nThis entity already has data...");
Xrecord myXrecord = (Xrecord) trans.GetObject(entryId, OpenMode.ForRead);
foreach (TypedValue value in myXrecord.Data)
{
ed.WriteMessage("\n" + value.TypeCode.ToString() + " . " + value.Value.ToString());
}
}
catch (Exception exception1)
{
ProjectData.SetProjectError(exception1);
nod.UpgradeOpen();
Xrecord myXrecord = new Xrecord();
TypedValue[] VB$t_array$S0 = new TypedValue[5];
TypedValue VB$t_struct$S0 = new TypedValue(70, 1);
VB$t_array$S0[0] = VB$t_struct$S0;
TypedValue VB$t_struct$S1 = new TypedValue(1, "MyCompanyDefaultSettings");
VB$t_array$S0[1] = VB$t_struct$S1;
TypedValue VB$t_struct$S2 = new TypedValue(40, 51.9);
VB$t_array$S0[2] = VB$t_struct$S2;
TypedValue VB$t_struct$S3 = new TypedValue(40, 100.0);
VB$t_array$S0[3] = VB$t_struct$S3;
TypedValue VB$t_struct$S4 = new TypedValue(40, 320.6);
VB$t_array$S0[4] = VB$t_struct$S4;
ResultBuffer data = new ResultBuffer(VB$t_array$S0);
myXrecord.Data = data;
nod.SetAt("MyData", myXrecord);
trans.AddNewlyCreatedDBObject(myXrecord, true);
ProjectData.ClearProjectError();
}
trans.Commit();
}
catch (Exception exception2)
{
ProjectData.SetProjectError(exception2);
Exception ex = exception2;
ed.WriteMessage("a problem occurred because " + ex.Message);
ProjectData.ClearProjectError();
}
finally
{
trans.Dispose();
}
}
-
All that VB nastiness!
-
Give this (http://www.theswamp.org/lilly_pond/GlennR/2007-11-16%20DevTvintro-CS.html) a whirl Kerry.
-
Just thought I should post the solution as well because of the UserControl.
-
I've just had one of 'those' thoughts ...
I wonder if doing the translation from VB to C# with Lutz Roeder's Reflector would be more efficient and accurate than using SharpDevelop ??
[addToListOfThingsToTest]
Do not know what of the demos you guys are using.... I download the first one on the list and opened on visual studio 2005, removed the debug to a2008, did the compile and open it using lutz reflector and getting something like:
[CommandMethod("addAnEnt")]
public void AddAnEnt()
{
///............
}
All that VB nastiness!
I tried the same Luis ... hardly ' pretty ' sample code, is it :-)
-
Just thought I should post the solution as well because of the UserControl.
DevTvIntroCS.zip (52.73 KB - downloaded 2 times.)
Thanks Glenn .. I'll have a look tonight when by head cools down.
....
Just a matter of style, what to you guys think about the comments preceding each code line ?
.. I 'spose it depends on your comfort level with the code ...
-
...er...that's it's a comment...?
What do you mean?
-
...er...that's it's a comment...?
What do you mean?
I found the quantity and regularity of comments in the original doc a little overpowering ...
In the editor I have turned the color of Comments to silver in the config so they're almost ignorable ..
.. but the comments tend to dominate in code posts and prints.
I 'spose I'm forgetting that this is/was sample/Example code.
.. just ignore me.
-
Just thought I should post the solution as well because of the UserControl.
Thanks, much better!
ps: why that sample was done using vb.net [if he started with c#]? [me like c#]
-
I've been turning mine to silver for years for the exact same reason...another reason I'm liking CopySourceAsHtml...preserves the colours as you've no doubt seen already.
Cheers,
Glenn.
-
As far as comments go, I read something recently which made a lot of sense - don't comment the obvious. An example of this in reference to the code samples we're discussing, would be the comment about getting the editor object...too obvious, therefor I wouldn't do it.
I put in most of the comments (got tired of doing it for the last 2 function/commands as you can see) to preserve what was done in the video for other 'starters' if you will.
I resisted the urge mightilly too I might add to rewrite it - some sections are...'not best practice' shall we say. However, I did change the odd thing here and there, with one of the major ones being I declared the palette and paletteset variables as private and static.
Cheers,
Glenn.
-
.... I resisted the urge mightilly too I might add to rewrite it - some sections are...'not best practice' shall we say.
Some of that could be atttributed to the 'Conversion' , some possibly to the writer trying to keep the sample relatively simple.
This is the primary reason why I would have liked to see the sample as "professionally written" C# code
..... it comes back to a long standing assertion of mine .. most people learn by osmosis ; show them/us enough less than optimal code and that standard becomes the accepted norm.
Thanks Glenn,
regards, Kerry.
-
Some of that could be atttributed to the 'Conversion'
There was no conversion on my part - I wrote it from scratch. I tend to agree with your comment about the writer keeping it simple...it is afterall an introduction. I also agree that they should lead by example as it were.
Cheers,
Glenn.
-
I finally got around to watching part of this video. I didn't download the source code, and now I'm glad I didn't.
-
This topic is old. Thought I might dust it off.