Updating parameter value

Updating parameter value

Anonymous
Not applicable
1,706 Views
9 Replies
Message 1 of 10

Updating parameter value

Anonymous
Not applicable

I am newbie for AutoCAD VB .NET programming.

I have a requirement to get a parameter value thro' VB .NET GUI and based on the value update a parameter in AutoCAD 2012 drawing (since my client is using AutoCAD 2012).

 

I read the post Update a parametric dimension value using .NET (C# or VB) and tried the code provided in

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

 

I converted the C# code provided in the above link to VB .NET and it works. But I am unable to enter a numeric value in the code.

I have attached my code and AutoCAD 2012 drawing file I am using.

 

The code seems to fail at

 Dim var As AssocVariable = TryCast(Tx.GetObject(variableId, OpenMode.ForWrite), AssocVariable)

 

Thanks

PV Subramanian

0 Likes
Accepted solutions (2)
1,707 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable

There is some issue with uploading attachments. I will upload after sometime.

Thanks

PV Subramanian

0 Likes
Message 3 of 10

Anonymous
Not applicable

Please find attached the AutoCAD VB .NET Program, sample AutoCAD 2012 drawing and the PPT containing the error message.

Thanks

PV Subramanian

0 Likes
Message 4 of 10

Anonymous
Not applicable

Please find attached the AutoCAD 2012 drawing and the PPT containing the error message

0 Likes
Message 5 of 10

Anonymous
Not applicable

Please find attached the PPT with error message

0 Likes
Message 6 of 10

Anonymous
Not applicable

I made some progress especially during this weekend after spending long hours

The issue seems to be related to VB .NET GUI and VB .NET program opeining the AutoCAD drawing

 

The program fails in the following statement (Tx.GetObject method fails when we try with ForWrite Open mode)

   Using Tx As Transaction = variableId.Database.TransactionManager.StartTransaction()

   Dim dbo As DBObject = Tx.GetObject(variableId, OpenMode.ForWrite)

 

The following are my observations after several experimentation

1) The parameters get updated and progrm works successfully - if there is no VB .NET GUI and the AutoCAD drawing is active & open

2) The parameters get updated and progrm works successfully - if there is modal VB .NET GUI (form.ShowDialog()) and the AutoCAD drawing is active & open

 

3) The parameters do not get updated and progrm fails - if there is modaless VB .NET GUI (form.Show()) and the AutoCAD drawing is active & open

4) The parameters do not get updated and progrm fails - if there is modal VB .NET GUI (form.ShowDialog()) and VB .NET opens the AutoCAD drawing

5) The parameters do not get updated and progrm fails - if there is modaless VB .NET GUI (form.Show()) and VB .NET opens the AutoCAD drawing

 

I have attached the program and the drawing. Appreciate any help

Thanks

PV Subramanian

0 Likes
Message 7 of 10

Alexander.Rivilis
Mentor
Mentor
Accepted solution

Adding or modifying the database from modeless dialog box.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 8 of 10

norman.yuan
Mentor
Mentor
Accepted solution
You do not use Form.Show/ShowDialog(). Instead, use Autodrsk.AutoCad.ApplicationServices.Application.ShowModelessDialog/ShowModalDialog().

When using modelss dialog, it is very likely you command is in session context (I.e. CommandFlsgs.Session is set). In this case, you need lock the document before modifying drawing database.

Also, it is by design that you cannot open a drawing document when a modal dialog box displays. This is different behaviour from Acad VBA.

Norman Yuan

Drive CAD With Code

EESignature

Message 9 of 10

Anonymous
Not applicable

Hi Alexander.Rivilis, Norman Yuan,

   Thanks for your solution. 

   All I had to do was to lock the drawing document before start of transaction. The code I added for lock is 

Using lock As Autodesk.AutoCAD.ApplicationServices.DocumentLock = doc.LockDocument()

   I have attached the updated code along with the sample drawing.

Thanks

PV Subramanian

0 Likes
Message 10 of 10

Anonymous
Not applicable

Please find the attachments

0 Likes