AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom Object Data Palette

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
CNinBC
1477 Views, 4 Replies

Custom Object Data Palette

CNinBC
Advocate
Advocate

I am working on a project to create a custom Object Data Palette in Civil 3D. the goal is to set up a palette for CAD user enter/copy/modify/audit the object data attached to the CAD entities. As of today, I managed to create a custom palette in Civil 3D, and added a few buttons and a grid for the data field. next, i will be trying to link the object data table function to the palette. I am new to C# programming, here is the list of the challenges I am facing, I would like to get some advice from the community. thanks in advance for any suggestion/advise/tips.

1. what is the best way to bring in the object data table into the dwg file (assuming the tables are not predefined in the drawing), I was going to use individual csv file to save each table, each csv file contains all data fields, and its possible value presets, but this method brings up another challenge for me - how to access external files.

2. how to access the object data in selected object(s) and show it on my palette, currently, I am using Grid component, is it correct object to be used for this purpose

3. is it possible to add a pull-down select box in the data entry field to allow pre-defined data value, for example, on the BASE table we have a data field called "SERVICE_STATUS", we have pre-defined data value "I" for "In Service", "NETN" for "New Acquisition", "REPL" for "Replacement", etc.

that's it for now. may come up more along the way.

attached below are the screenshot of my custom palette I made so far and a sample object data table (we have about 15+- tables, each table contains 15+- data fields)

the software I am using is Civil 3D 2015 and Microsoft Visual Studio 2012 Express

Thanks again.

 

bby.PNGbby2.PNG

0 Likes

Custom Object Data Palette

I am working on a project to create a custom Object Data Palette in Civil 3D. the goal is to set up a palette for CAD user enter/copy/modify/audit the object data attached to the CAD entities. As of today, I managed to create a custom palette in Civil 3D, and added a few buttons and a grid for the data field. next, i will be trying to link the object data table function to the palette. I am new to C# programming, here is the list of the challenges I am facing, I would like to get some advice from the community. thanks in advance for any suggestion/advise/tips.

1. what is the best way to bring in the object data table into the dwg file (assuming the tables are not predefined in the drawing), I was going to use individual csv file to save each table, each csv file contains all data fields, and its possible value presets, but this method brings up another challenge for me - how to access external files.

2. how to access the object data in selected object(s) and show it on my palette, currently, I am using Grid component, is it correct object to be used for this purpose

3. is it possible to add a pull-down select box in the data entry field to allow pre-defined data value, for example, on the BASE table we have a data field called "SERVICE_STATUS", we have pre-defined data value "I" for "In Service", "NETN" for "New Acquisition", "REPL" for "Replacement", etc.

that's it for now. may come up more along the way.

attached below are the screenshot of my custom palette I made so far and a sample object data table (we have about 15+- tables, each table contains 15+- data fields)

the software I am using is Civil 3D 2015 and Microsoft Visual Studio 2012 Express

Thanks again.

 

bby.PNGbby2.PNG

4 REPLIES 4
Message 2 of 5
norman.yuan
in reply to: CNinBC

norman.yuan
Mentor
Mentor
Accepted solution

To develop a good solution to what you described, besides the good understanding of the business process (how the object data is used, organized...), the skill and knowledge of AutoCAD programming (.NET APIs, mainly) and MS .NET framework (regardless of using C# or VB.NET) would decide the quality/usability of your application.

 

Your solution should be structured in multipe tiers(layers), and each focuses on specific works:

 

1. OD table defining/configuring. This should be mostly non-coding task. You can define your OD table in text/csv file, XML file, or even better in a database in intranet network, or even somewhere in the cloud). You need to be aware that eventaully the OD table definition data (text file, or database tables) should be managed by business leader (CAD manager, for example), not programmer. So, they should not have to look at the data and try to figure it out what does it mean in term of definition an Object Data table. Thus, there may be need to have a seperate app to provide easy-to-follow UI for business leader to configure custom object data tables/fields... Mind you, this UI/app in general is not meant for every CAD users who deal with Object Data in drawing.

 

2. The you should organize all the code that access OD table configurations, manipulating OD data in drawing into another tier, which covers all business logics that deal with Object Data, such as in which cases specific OD tables are needed to be created, validated, removed from a drawing, targeting certain types of entities to attach/detach OD records, searcing/querying OD ata in drawing...

 

3. The UI tier shown in AutoCAd for user to deal with OD table/data.

 

Using PaletteSet/modeless dialog is required rather advanced AutoCAD .NET knowledge if the data shown UI is "per document" based (in your case, showing custom OD data is very likely "per document" based): because the currently active document ccan change while the UI is visible, thus the data shown there must be syched with the activate document change. There are different ways to may the modeless UI to interact with data from drawing, but I found that when working with PaletteSet, using WPF with MVVM patterns would be much better approach.

 

As per your pointed questions:

 

1. The best way to bring data table (definition/configuration) from backend (be text/CSV file, or database), would be define a data acccess Interface, so that the code in AUtoCAD side only deals with the Interface object witjout having to know how/where the data is from. I am not sure if you know the concept of separating one process from other with Interface. With Interface sits between AutoCAD app and your OD table definition data, whatever you do to the OD definition data (being each table a file, or one file covers all OD tables, or using XML. or using database), it would not affect the code on AutoCAD.

 

2. The cod for accessing OD data in drawing should in different tiers as the code for UI. Do not mix them together, such as in your button click event handler:

 

you do not do:

 

private void MyButton_Click(...)

{

   ''Go to MdiActiveDocument

   '' Search OD data

   '' change OD data, fi necessary

   '' Update UI, be it Grid, or not

}

 

you do

private void MyButton_Click(...)

{

   '' Get MdiActiveDrawing

   '' A tier2Class.Dosomething(mdiActveDwg)

   '' Based on Tier2.Class' execution result, update UI

}

 

3. Yes, of course you can use dropdown/combobox to show available OD Table (name, fields, data type, value range...) Again, you do not reach the OD table definition directly from UI. Use middle tier class to access OD table definition data, and return them back to UI.

 

One more thing, while Object Data has been around for quite a while, I found Autodesk managed to make bad things happen to it from versions to versions, oftern something got broken in this version and fixed in aother, and new break somehow introduced, and so one. I have being using Civil3D2015 in past 3 years, and ran into some bad things on OD Data side that do not exist in AutoCAD Map 2015, nor in Civil2017/2018 (I never tried Civil2016). So, if possible, I'd suggest based on your develop on later Civil3D version than 2015, if possible. I am pretty sure with what you intend to do, it would take a while to get fully worked as expected. By then Civil3D 2015 would be "too" old version.

Norman Yuan

Drive CAD With Code

EESignature

To develop a good solution to what you described, besides the good understanding of the business process (how the object data is used, organized...), the skill and knowledge of AutoCAD programming (.NET APIs, mainly) and MS .NET framework (regardless of using C# or VB.NET) would decide the quality/usability of your application.

 

Your solution should be structured in multipe tiers(layers), and each focuses on specific works:

 

1. OD table defining/configuring. This should be mostly non-coding task. You can define your OD table in text/csv file, XML file, or even better in a database in intranet network, or even somewhere in the cloud). You need to be aware that eventaully the OD table definition data (text file, or database tables) should be managed by business leader (CAD manager, for example), not programmer. So, they should not have to look at the data and try to figure it out what does it mean in term of definition an Object Data table. Thus, there may be need to have a seperate app to provide easy-to-follow UI for business leader to configure custom object data tables/fields... Mind you, this UI/app in general is not meant for every CAD users who deal with Object Data in drawing.

 

2. The you should organize all the code that access OD table configurations, manipulating OD data in drawing into another tier, which covers all business logics that deal with Object Data, such as in which cases specific OD tables are needed to be created, validated, removed from a drawing, targeting certain types of entities to attach/detach OD records, searcing/querying OD ata in drawing...

 

3. The UI tier shown in AutoCAd for user to deal with OD table/data.

 

Using PaletteSet/modeless dialog is required rather advanced AutoCAD .NET knowledge if the data shown UI is "per document" based (in your case, showing custom OD data is very likely "per document" based): because the currently active document ccan change while the UI is visible, thus the data shown there must be syched with the activate document change. There are different ways to may the modeless UI to interact with data from drawing, but I found that when working with PaletteSet, using WPF with MVVM patterns would be much better approach.

 

As per your pointed questions:

 

1. The best way to bring data table (definition/configuration) from backend (be text/CSV file, or database), would be define a data acccess Interface, so that the code in AUtoCAD side only deals with the Interface object witjout having to know how/where the data is from. I am not sure if you know the concept of separating one process from other with Interface. With Interface sits between AutoCAD app and your OD table definition data, whatever you do to the OD definition data (being each table a file, or one file covers all OD tables, or using XML. or using database), it would not affect the code on AutoCAD.

 

2. The cod for accessing OD data in drawing should in different tiers as the code for UI. Do not mix them together, such as in your button click event handler:

 

you do not do:

 

private void MyButton_Click(...)

{

   ''Go to MdiActiveDocument

   '' Search OD data

   '' change OD data, fi necessary

   '' Update UI, be it Grid, or not

}

 

you do

private void MyButton_Click(...)

{

   '' Get MdiActiveDrawing

   '' A tier2Class.Dosomething(mdiActveDwg)

   '' Based on Tier2.Class' execution result, update UI

}

 

3. Yes, of course you can use dropdown/combobox to show available OD Table (name, fields, data type, value range...) Again, you do not reach the OD table definition directly from UI. Use middle tier class to access OD table definition data, and return them back to UI.

 

One more thing, while Object Data has been around for quite a while, I found Autodesk managed to make bad things happen to it from versions to versions, oftern something got broken in this version and fixed in aother, and new break somehow introduced, and so one. I have being using Civil3D2015 in past 3 years, and ran into some bad things on OD Data side that do not exist in AutoCAD Map 2015, nor in Civil2017/2018 (I never tried Civil2016). So, if possible, I'd suggest based on your develop on later Civil3D version than 2015, if possible. I am pretty sure with what you intend to do, it would take a while to get fully worked as expected. By then Civil3D 2015 would be "too" old version.

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 5
CNinBC
in reply to: norman.yuan

CNinBC
Advocate
Advocate

Hi Norman,

 

Thanks for your explanation. I am the CAD manager with little programming background for our team. I used to write PASCAL code in DOS when I was a student, I am still not fully understand how this .net framework and API library work, and how to figure out which API function to use, etc.  Even though I have written some C# code to enhance the C3D function for our group, however those were done by reading lots of sample coding on the internet, and then made my owe. But for object data table, I can't find enough samples to learn how related APIs work in conjunction with the custom tool palette in Autocad.

 

If reading the table definition from external source is too complicate, I will ignore it for now, because as long as I stay in the company, I am the person to update this code & the table, I don't worry about the UI for the CAD manager. the worst case, i will bring in the object data table by copy & paste the objects contain tables from the template.

 

 

the first main goal for me is to implement the data table palette, and let CAD user can use the palette to attach/read/modify data table to polyline(s) based on the object layer.

 

if I assume the tables are already in the current drawing, how can I display the table picked from the pull down list onto the grid and let user to manually enter the value (ignore those preset for now)? how does my program assess the tables in the current drawing or attached to the selected object?

 

Thanks.

 

Capture222.PNG

 

 

 

0 Likes

Hi Norman,

 

Thanks for your explanation. I am the CAD manager with little programming background for our team. I used to write PASCAL code in DOS when I was a student, I am still not fully understand how this .net framework and API library work, and how to figure out which API function to use, etc.  Even though I have written some C# code to enhance the C3D function for our group, however those were done by reading lots of sample coding on the internet, and then made my owe. But for object data table, I can't find enough samples to learn how related APIs work in conjunction with the custom tool palette in Autocad.

 

If reading the table definition from external source is too complicate, I will ignore it for now, because as long as I stay in the company, I am the person to update this code & the table, I don't worry about the UI for the CAD manager. the worst case, i will bring in the object data table by copy & paste the objects contain tables from the template.

 

 

the first main goal for me is to implement the data table palette, and let CAD user can use the palette to attach/read/modify data table to polyline(s) based on the object layer.

 

if I assume the tables are already in the current drawing, how can I display the table picked from the pull down list onto the grid and let user to manually enter the value (ignore those preset for now)? how does my program assess the tables in the current drawing or attached to the selected object?

 

Thanks.

 

Capture222.PNG

 

 

 

Message 4 of 5
norman.yuan
in reply to: CNinBC

norman.yuan
Mentor
Mentor

Considering what you said on your knowledge/experience of programming, I'd recommend (besides very basic AutoCAD .NET API):

 

1. Start from how to use AutoCAD MAP .NET API to acccess Object Data objects in drawing: creating/deleting OD tables; attaching/detaching OD records to entiities, retrieving( reading) data from OD record of an entity... Once you are able to access/manipulate OD data in drawing, then you can structure yyour code/application in a better way to present in UI.

 

You can start with the .NET code samples coming with AutoCAD MAP PbjectARX SDK.

 

2. Try do to UI in dialog box (Modal Dialog, rather than floating dialog/PaletteSet) first. If you want to go straight to PaletteSet/floating dialog form, make sure you understanding how to handle various Document/DocumentCollection events, so that the PaletteSet can be updated based on current active document. You may also need to find a good way to store/cache Object Data already obtained from each open drawings (you do not want to search drawing for OD data each time active drawing is switched: searching OD data in a drawing could be very time-consuming process, depending on how many entities in drawing to search).

Norman Yuan

Drive CAD With Code

EESignature

0 Likes

Considering what you said on your knowledge/experience of programming, I'd recommend (besides very basic AutoCAD .NET API):

 

1. Start from how to use AutoCAD MAP .NET API to acccess Object Data objects in drawing: creating/deleting OD tables; attaching/detaching OD records to entiities, retrieving( reading) data from OD record of an entity... Once you are able to access/manipulate OD data in drawing, then you can structure yyour code/application in a better way to present in UI.

 

You can start with the .NET code samples coming with AutoCAD MAP PbjectARX SDK.

 

2. Try do to UI in dialog box (Modal Dialog, rather than floating dialog/PaletteSet) first. If you want to go straight to PaletteSet/floating dialog form, make sure you understanding how to handle various Document/DocumentCollection events, so that the PaletteSet can be updated based on current active document. You may also need to find a good way to store/cache Object Data already obtained from each open drawings (you do not want to search drawing for OD data each time active drawing is switched: searching OD data in a drawing could be very time-consuming process, depending on how many entities in drawing to search).

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 5
CNinBC
in reply to: norman.yuan

CNinBC
Advocate
Advocate

Thanks Norman, I will give it a try.

0 Likes

Thanks Norman, I will give it a try.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report