PDA

View Full Version : SPPID 2007 Placie. Place doesn't send changes to DB?



DimitryAT
11-09-2010, 11:07 PM
Hello all, and good morning!

I have strange problem with Placie and Llama in SPPID 2007:
I use Placie to delete some objects on drawing, and place new objects.
It works, but then I try to read information from this objects, I can't!
Also, If I run my delete-place procedure again, it doesn't delete this newly created objects.

It seems like Place put deleted and created objects in some kind of memory cache, and not send to database,
but filters work on the database data, so filters don't see any changes.

Do someone have already this kind of problems?
I can provide some code if it helps.

Thanks

Paulo
11-10-2010, 04:21 AM
Did you try to commit the operation?

objSymbol.commit

dave
11-10-2010, 12:38 PM
also dont forget

(outside the loop)
datasource.begintransaction

(inside the loop)
objThing.commit

(outside the loop)
datasource.committransaction



datasource.begintransaction
for each thing in things
thing = x
thing.commit
next
datasource.committransaction

DimitryAT
11-11-2010, 12:55 AM
Thanks for your hints, but I try do it in this way already, and it is not work.
And, I'm not really sure than we need commit operation of placing or deleting.
As far as I know, we don't need begintransaction\committransaction if we don't need use transaction mechanism and pissibility to rollback it
but I already add it to code and try - it not work.
My code is VERY simple,
it uses filter to get ItemNotes on drawing
delete them
place new
use filter to get ItemNotes again



Private Function PlaceNotes(m_placement As Placement, ByVal SymbolName As String) As Integer
Dim objSymbol As LMSymbol
PlaceNotes = 0
m_placement.PIDDataSource.BeginTransaction ' we don't need it and it doesn't help?
For i = 0 To 5

Set objSymbol = m_placement.PIDPlaceSymbol(SymbolName, 0.67, 0.5 - 0.005 * i, 0, 0)
If Not objSymbol Is Nothing Then

objSymbol.ModelItemObject.Attributes("Note.Body").Value = "Test note " & CStr(i) & CStr(Rnd)
objSymbol.ModelItemObject.Commit
objSymbol.Commit 'i think this is not really necessary?

PlaceNotes = PlaceNotes + 1
End If

Next i
m_placement.PIDDataSource.CommitTransaction
m_placement.PIDDataSource.Flush 'this also not help?
Set objSymbol = Nothing
End Function


How can I add zip file with source code if it is possible?

dave
11-11-2010, 07:06 AM
DimitryAT, just attach the zip to the post.

Do you really have a property called "Note.Body"?

DimitryAT
11-12-2010, 02:12 AM
DimitryAT, just attach the zip to the post.
Do you really have a property called "Note.Body"?
Yes, I surely have property "Note.Body".

PS: Then I try to attach zip file, using "Go Advanced", then Attachments, then Select file - I can't choose zip file.
I think reason is - valid file extension is: " bmp doc dwg gif jpe jpeg jpg pdf png psd txt"

PPS:
I upload it to UploadBox, http://uploadbox.com/files/67bfb46ab1/
but I don't like it - it shows advs and timer.
So I upload it to http://rghost.net/3229152

Paulo
11-12-2010, 02:17 AM
DimitryAT
Try this code for example. You should make reference to LMAITEM to access "Note.Body".


Sub PlaceItem()
Dim objSymbol As LMSymbol
Dim objPlacement As Placement
Dim strSymbolPath As String
Dim objItem As LMAItem

Dim x As Integer

Set objPlacement = New Placement
strSymbolPath = "SymbolPath"

For i = 0 To 5
Set objSymbol = objPlacement.PIDPlaceSymbol(strSymbolPath, 0.67, 0.5 - 0.005 * i, 0, 0)
Set objItem = objSymbol.ModelItemObject
For x = 1 To objSymbol.Attributes.Count
objItem.Attributes("Note.Body").Value = "Test Auto " & i
Next
Next

End Sub

DimitryAT
11-12-2010, 02:25 AM
Hi Paulo,
I will try it, but is it really good try to update 1 attribute "Note.Body" so much times?


For x = 1 To objSymbol.Attributes.Count
objItem.Attributes("Note.Body").Value = "Test Auto " & i
Next

Paulo
11-12-2010, 02:54 AM
My mistake...
Do not consider this "For".
The code will create five Notes and will update the field "Body" of each one of them.

OZ10
11-17-2010, 12:42 AM
I've had all sorts of problems with placement and database commitment. Some times it works, some times it doesn't.
A good 'catch-all' that I found was to either save the active drawing, or if that fails, close the drawing.

Dim PID As PIDAutomation.Application
PID.ActiveDrawing.Save

dave
01-24-2011, 10:19 PM
Sorry I couldn't be more help here OZ, I have not worked with the Plaice functionality at all. (outside the training class)

Glad you found a semi solution.