ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating and using custom user variables

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Bica.Bogdan
2354 Views, 9 Replies

Creating and using custom user variables

Hello,

I am trying to find a way to create custom user variables (eg. Construction Location, Builder, Arhitect, or numerical values) which can be inserted throughout the project in AcDbMTexts or AcDbTables and get updated automatically each if the variable is modified. 

Initially i tried using AcDbField, but i found no way of creating custom fields. Still, some of the default values there will prove usefull.

Is there an AcDbField dictionary, or how can i access the list of available fields?

Now i am looking into AcDbAssocVariable, but i don't know how i could add them to AcDbMTexts, or how to update them.

Any suggestions or samples i could look at?

9 REPLIES 9
Message 2 of 10
owenwengerd
in reply to: Bica.Bogdan

Maybe store your variable values as drawing properties (aka DWGPROPS), then use a field to evaluate them?

--
Owen Wengerd
ManuSoft
Message 3 of 10
Bica.Bogdan
in reply to: Bica.Bogdan

That worked, thanks a lot. I used acdbGetSummaryInfo to get the db's AcDbDatabaseSummaryInfo, added some CustomSummaryInfo and commited the modified AcDbDatabaseSummaryInfo with acdbPutSummaryInfo.

And i have more questions then. 

How do i get the database's field dictionary?

Is setField() necessary? I was able to add fields by simply inserting the fieldCode in the AcDbMText's contents, fields which were automatically created when i added CustomSummaryInfo to the database's AcDbDatabaseSummaryInfo.

 

 

Message 4 of 10
Bica.Bogdan
in reply to: Bica.Bogdan

Also, i have no idea how i can set dependencies between variables, which are updated automatically.

I could use the reactor attached to AcDbDatabaseSummaryInfo, but there has to be a better way.

I also need to be able to allow only some types of data to be inserted in some variables, Int, double, etc

Message 5 of 10
Bica.Bogdan
in reply to: Bica.Bogdan

I must have been blind not the see AcDbObject's GetFieldDictionary, which also works for model space? No time to see today, i'll try it out on monday/

Message 6 of 10

Hi

 

Attached is a sample that illustrates how to create a custom field, I extracted this sample from arx sdk 2009,  it will require migration depending of your AutoCAD version. This is the desc from sdk:

 

 

The TextFileField sample defines a custom field in a DBX module and provides the accompanying
User Interface integration in an ARX module. The custom field reads in the contents of an external text file and returns that to the framework, providing funcionality that is comparable to the RTEXT object found in the AutoCAD EXpress Tools.

 

Here is a blog post where I exposed assoc variables with the associative framework:

 

http://adndevblog.typepad.com/autocad/2012/03/working-with-associative-parameters-from-api.html

 

Also a hig level toolkit to work with that API:

 

http://adndevblog.typepad.com/autocad/2013/01/a-simplified-net-api-for-accessing-autocad-parameters-...

 

I suggest you take a look at those before you decide how to handle your requirement.

 

The assoc variables can provide the dependency mechanism you are looking for, but I don't think you can use them directly in a field. You could combine assoc variable and a custom field maybe. The drawing properties with a reactor could also work as you mentioned previously, but you would have to handle the dependency logic.

 

Concerning restricting the property type, you would need to filter that in a custom dialog, the AutoCAD native input dialogs are usually not customizable.

 

I hope it helps,

Philippe.

 

 

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 7 of 10

Thank you very much Philippe, i will look into the samples you provided.

Message 8 of 10
Bica.Bogdan
in reply to: Bica.Bogdan

The sample Philippe provided helped us a lot, it actually did most of the work 🙂

One further question. Our variables are structured in tree like categories.

Is there any way we can overide the field name "list" in the Field Dialog to a tree list?

Theoretically, i could use the field names list as a secondary category and implement my own controls, including trees in the Option Dialog, but the first option would obviously be a cleaner solution. If overriding the field name list is the only way possible, can i at least change the field name static to another one?

Thanks, have a great day

Message 9 of 10

There is no way you can modify AutoCAD native dialogs, other than "hacking" them with some low level approach relying on Win32 API's, if at all possible.

 

I hope it answers the question.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 10 of 10
Bica.Bogdan
in reply to: Bica.Bogdan

There is no way you can modify AutoCAD native dialogs, other than "hacking" them with some low level approach relying on Win32 API's, if at all possible.

 

....and steal some banking info while i'm at it Smiley Tongue 😛 

Thanks Philippe, you've been of great help. (no sarcasm)

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

Post to forums  

Autodesk Design & Make Report

”Boost