Author Topic: Lets write a complete real world add-in  (Read 9286 times)

0 Members and 1 Guest are viewing this topic.

BlackBox

  • King Gator
  • Posts: 3745
Re: Lets write a complete real world add-in
« Reply #30 on: July 13, 2012, 05:58:38 AM »
The ability to write custom properties with out the need to open AutoCAD ??

Yep, like I said before.

The app that you linked reads the properties, There is no write ability of custom properties with out opening autocad or truedwg.

Perhaps I misunderstood... This is what I read. I am not sure how or why one would write custom properties without one of those installed (they'd still require RealDWG, no?). Maybe this just doesn't make sense to me due to the nature of my work.

In any event this may or may not help to clarify... I'm here to help, so if JTB's gimmick is not what you're after, and others are interested in contributing code to your idea, then I am in.  :-)

Quote from: JTB World's DwgInfoTip

About

    Enhance Your User's Experience with the New DWG Infotip Shell Extension.
    Show the DWG properties as an Infotip (tooltip) in Explorer or even from file dialog boxes within AutoCAD.



    Use DWGPROPS in AutoCAD and add information in the Summary or Custom tabs and it will show up just hovering above a DWG file.
    The Infotip will show the version of the DWG file, file size, date modified and most property information.
    PROPULATE allows quick, automated population of the Drawing Properties dialog data fields.
    No need to have AutoCAD installed. That means that everyone at your company can see this information.
    No need to open the drawing to know information like revision and other valuable information in the drawing.

<snip>

The freeware version is showing the DWG file format and title.



See also the complementary application DWG Columns for Explorer to show the information in columns in Explorer.
"How we think determines what we do, and what we do determines what we get."

Jeff H

  • Needs a day job
  • Posts: 6055
Re: Lets write a complete real world add-in
« Reply #31 on: July 13, 2012, 01:56:32 PM »
I have been at a condo made for kids getting mildy liquored up and running around in splash pads and the beach with my kid for the last couple of days, but one of main reasons for doing this was to start creating a base library that could reused over and over for other projects.
 
So without much thought we first need to decide how to set up the base libraies.
We need to think about the changes with 2013 and plan on working with 2013.
Should we break it up into 2 dll's where one is the core and meant for running with the core console and another that is only needed for running inside AutoCAD.
 
The main point was to start collaborating to create little projects but in turn have other peoples input for creating library code.
 
For example with the open and close of drawings we need to know when drawings are created and destroyed, and instead creating something project specific we could do something like have an Interface IDocumentLifetime and it call DocCreated and DocDestroyed for each class that implements the interface.
 
I am on the road and hopefully it makes sense and will reply back later when get home and sobered up a bit.

Jeff H

  • Needs a day job
  • Posts: 6055
Re: Lets write a complete real world add-in
« Reply #32 on: July 14, 2012, 02:20:10 PM »
This should test the juices.

Rescale a Template drawing. ( assume the drawing is current active doc.)

Will deal with dims, linetypes and LinetypeScales, TextStyles, Units, Metric(etc)


The routine should work an a 'used' drawing too ..
Any existing displayed entitys should NOT change in size or location.  ....


.. just a thought.



and the next step :
a startup routine to set user settings.

 :)
I think that would be a good starter then the open close drawing thing , and will post something later with an example and expalnation on intent and and how I think this community could help produce some good learning material and hopefully with minor tweaks could be used for production code.
 but I tend to be a little tardish and do not quite understand how to scale them without changing size?
Overruling the WorldDraw?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Lets write a complete real world add-in
« Reply #33 on: July 14, 2012, 08:06:04 PM »
The intent would be to only change the annotative and presentation things.

The objects being presented remain at 1:1 ( as they should)


The border may change scale to contain the objects but that would be a seperate operation.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

vegbruiser

  • Guest
Re: Lets write a complete real world add-in
« Reply #34 on: July 16, 2012, 04:21:09 AM »
If it's any help, I've done some work in the past with dynamic blocks that we used for drawing borders (in Paperspace) - we had several size settings (A3 thru' A0) and were able to change the size according to the settings used on a block within ModelSpace. (the original aim of the add-in was to standardize as much as possible the output from a design team of around 20+ designers and it's worked pretty well for the best part of 6 years)

My original code for this was written in VBA for AutoCAD 2006, but I've been slowly porting it across to newer versions of AutoCAD using C#.NET

Jeff H

  • Needs a day job
  • Posts: 6055
Re: Lets write a complete real world add-in
« Reply #35 on: July 16, 2012, 04:27:14 AM »
Thanks Alex,
 
That would would be great!
 
I am still trying to prepare a decent post and should have it ready today.
 

Jeff H

  • Needs a day job
  • Posts: 6055
Re: Lets write a complete real world add-in
« Reply #36 on: July 25, 2012, 09:48:09 PM »
Hopefully people are still interested, and been busy but almost got little something together.
« Last Edit: July 25, 2012, 11:15:19 PM by Jeff H »

vegbruiser

  • Guest
Re: Lets write a complete real world add-in
« Reply #37 on: July 26, 2012, 07:01:45 AM »
Sounds good Jeff, I'll gladly take a look at whatever you've got. :)

BlackBox

  • King Gator
  • Posts: 3745
Re: Lets write a complete real world add-in
« Reply #38 on: July 26, 2012, 08:15:09 AM »
Hopefully people are still interested...

1+  :mrgreen:
"How we think determines what we do, and what we do determines what we get."

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Lets write a complete real world add-in
« Reply #39 on: July 26, 2012, 12:28:07 PM »
+2  :-)
Revit 2019, AMEP 2019 64bit Win 10

Irvin

  • Guest
Re: Lets write a complete real world add-in
« Reply #40 on: August 02, 2012, 09:59:10 AM »
Hi guys,

I like this idea alot. I've tryed to start a similar threat on the Autdesk Forum. Not alot of people where interested.
I'm hopeing the community is alot better here. So i'll post the code i've written when i've got a bit more time.

For now i'll post a link from the Autodesk discussion forum.

http://forums.autodesk.com/t5/NET/Discussion-Group-ClassLibrary-please-read/m-p/3021058#M23522

Irvin

Jeff H

  • Needs a day job
  • Posts: 6055
Re: Lets write a complete real world add-in
« Reply #41 on: August 02, 2012, 06:09:19 PM »
I think it would be great to create some libraries that could used to help development. Unless correctly implemented it would waste peopleís time and resources and fall flat on its face.
   
Probably the first thing to do is define what it is we would want to accomplish and see if it is feasible then decide if the knowledge and resources are available for accomplishing such a task.
 
I could be completely wrong but I think they did a pretty good job designing the .NET base libraries. So we could learn from their experiences, user studies, etc.. 
 
Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries  looks like good book and from looking through it they seem pretty honest by including examples how they messed and should have done it differently.
 
 


 
If we decide to attempt this type of project I would expect everyone to scrutinize any ideas and hopefully everyone understands it is not personal but for producing a better result.
I will be the first to admit that I do NOT possess the knowledge or experience to design such a framework and could be steering efforts in wrong direction so please reply with your thoughts.
 
 


 
To create a library that others would use this might be start for some guidelines and concepts. I missed many points and every situation differs and needs to be decided on a individual basis but maybe this will get feedback started to see if it could be accomplished, defining exactly what to accomplish, etc....
 
 


For starters a definition.
 
Framework Ė reusable object-orientated libraries.
 
 
 
Qualities of a well designed Framework
 
  • Simple & Powerful
  • If something seems complex or double guessing complexity should probably not add it. You cannot remove but you can always add.
  • Expensive
  • Money and/or many hours and resources will have to go into well designed Framework. This will not happen magically. 
  • Trade-offs   
  • There is no perfect design and will have trade-offs. There is no one answer that will fit all and need to decide which the correct ones are.
  • Borrows from the past
  • Designed to evolve
  • Consistent
 



Designing a Framework
 
  • Should be Progressive
  • Knowledge learned from simple less advanced scenarios should be able to transfer to more advanced scenarios
  • Scenario driven
  • Invest your time in most common used scenarios
  • Write code samples first for main scenarios then define the object model.
  • Before designing the object model write code samples first then create object model from samples. A good test would be for each person to write some code how they would imagine or like to write code for scenarios. Many standard object-oriented design methodologies were created to help maintain the result from implementing the design model, not for usability of a public API.
  • Limit Abstractions
  • Standard object-oriented design methodologies tend to produce many abstractions. Frameworks with many abstractions usually force the user to learn the architecture of the framework when they could just spend the time learning the AutoCAD framework directly. Keep in mind many design patterns and object oriented techniques were never created or claim to optimize for this type of design, but aimed toward internal architecture. Of course abstractions have their place in a framework design.
  • Principle of Low Barrier to Entry.
  • Easy identification of the right set of types and members for common programming tasks. A namespace that holds types for common scenarios should only contain the types needed. Types needed for more advanced uses could be in placed in sub-namespaces which the common types could also use.
  • Should be able to use types immediately and not require extensive intialization
  • Easy to find and fix incorrect uses of API, exceptions should clearly describe what needs to be done.
  • Principle of Self-Documenting Object Models
  • Naming
  • Exceptions
  • Strong Typing
  • Consistency
  • Principle of Layered Architecture
  • One method is to put high and low level types in different but related namespaces.
 

dgorsman

  • Water Moccasin
  • Posts: 2402
Re: Lets write a complete real world add-in
« Reply #42 on: August 02, 2012, 06:46:46 PM »
In that vein, "We, The Developers,..." would be doing the heavy lifting in the implementation.  Other developers would take the product and use it rather than having to spend time doing extra work in an area they don't necessarily want to be an expert in.  The immediate examples that spring to mind, are matrix calculations (used heavily in transformations) and advanced mathematics (vector math, for one).  These would be implemented as used in AutoCAD, with Intellisense and documentation to guide the inputs and outputs so the end user wouldn't necessarily know how to calculate the inverse of a 4x4 matrix of doubles but would be familiar with "I need to transform this line so its end points match these two known points"; or not know how to calculate the intersection of a plane and bounded line but be familiar with "I have a 3D face and a line object, where do they intersect?".
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

Irvin

  • Guest
Re: Lets write a complete real world add-in
« Reply #43 on: August 06, 2012, 09:12:55 AM »
Hi guys,

In my opinion the first thing you need when developing an application is a place to store the applications settings. For example the default font for creating a new textstyle/dimstyle, a dwg for a dimblock for a new dimensionstyle or leader. This isnít AutoCAD related but almost every app has settings. I think this could a great starting point.

When you write a class for creating a new textstyle this class should look at the settings what font the user wants when we create the textstyle for him.

My personal preference for storing these kind of settings are in a database (MS-SQL compact) or we need to extend the AutoCAD profile within the registry. Iím not a great fan of using the appsettings within a project. Because these settings a stored in the acad.exe.config file and not in the applications.config file.

Hope you guyís share my thoughts about this issue. Letís define are preferences and start coding!

Irvin

Jeff H

  • Needs a day job
  • Posts: 6055
Re: Lets write a complete real world add-in
« Reply #44 on: August 06, 2012, 07:11:53 PM »
Depending on what you are trying to accomplish you could store them in AppData folder or search for Tony's Custom system variables.
Code - C#: [Select]
  1.  
  2.      public class MySettings
  3.     {
  4.         [XmlElement("num")]
  5.         public int MyNumber { get; set; }
  6.          [XmlElement("str")]
  7.         public string MyString { get; set; }
  8.         public void Save()
  9.         {
  10.             using (Stream stream = File.Create(SettingsFile))
  11.             {
  12.                 XmlSerializer ser = new XmlSerializer(this.GetType());
  13.                 ser.Serialize(stream, this);
  14.             }
  15.         }
  16.         public static MySettings Load()
  17.         {
  18.             if (!File.Exists(SettingsFile))
  19.                 return DefaultSettings;
  20.             using (Stream stream = File.OpenRead(SettingsFile))
  21.             {
  22.                 try
  23.                 {
  24.                     XmlSerializer ser = new XmlSerializer(typeof(MySettings));
  25.                     return (MySettings)ser.Deserialize(stream);
  26.                 }
  27.                 catch (InvalidOperationException)
  28.                 {
  29.                     stream.Close();
  30.                     File.Delete(SettingsFile);
  31.                     return DefaultSettings;
  32.                 }
  33.             }
  34.         }
  35.  
  36.         private static string SettingsFolder
  37.         {
  38.             get
  39.             {
  40.                 string folder = Environment.GetFolderPath(
  41.                     Environment.SpecialFolder.ApplicationData);
  42.                 folder = Path.Combine(folder, "MyCompany");
  43.                 folder = Path.Combine(folder, "MyApp");
  44.                 if (!Directory.Exists(folder))
  45.                     Directory.CreateDirectory(folder);
  46.                 return folder;
  47.             }
  48.         }
  49.         private static string SettingsFile
  50.         {
  51.             get
  52.             {
  53.                 return Path.Combine(SettingsFolder, "settings.xml");
  54.             }
  55.         }
  56.         private static MySettings DefaultSettings
  57.         {
  58.             get
  59.             {
  60.                 return new MySettings
  61.                 {
  62.                     MyNumber = 0,
  63.                     MyString = "",
  64.                 };
  65.             }
  66.         }
  67.     }
  68.  
« Last Edit: August 06, 2012, 07:39:46 PM by Jeff H »