Author Topic: Wblockclone  (Read 2290 times)

0 Members and 1 Guest are viewing this topic.

quamper

  • Guest
Wblockclone
« on: October 29, 2007, 11:16:21 PM »
I'm trying to do something similar to what MickD was asking in this thread http://www.theswamp.org/index.php?topic=10741.0

I work in VB.Net but I think I followed along with the general idea of it, as I was pretty much on that track anyways. However that code is copying one item at a time using getentity? I was able to get it to create a file with a single object using getentity and that worked fine. But can I do this with a selection set instead of one item at a time?

It will create the dwg for me but when I open it there is nothing in it. I'm sure I'm fouled up in my logic somewhere.

Code: [Select]
Dim myEd As Editor
Dim myPSR As PromptSelectionResult
Dim mySS As SelectionSet
Dim NewDB As Database
Dim NewTransMan As DatabaseServices.TransactionManager
Dim NewTrans As Transaction
Dim NewBT As BlockTable
Dim NewBTR As BlockTableRecord

NewDB = New Database(True, True)
NewTransMan = NewDB.TransactionManager
NewTrans = NewTransMan.StartTransaction
NewBT = NewDB.BlockTableId.GetObject(OpenMode.ForWrite)
NewBTR = NewBT(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)

myEd = Application.DocumentManager.MdiActiveDocument.Editor
myPSR = myEd.GetSelection       
mySS = myPSR.Value
myObjIds = New ObjectIdCollection(mySS.GetObjectIds)
NewDB.WblockCloneObjects(myObjIds., NewBT.ObjectId, myMap, DuplicateRecordCloning.Replace, False)
NewTrans.Commit()
NewDB.SaveAs("c:\testing\test.dwg", DwgVersion.AC1015)

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: Wblockclone
« Reply #1 on: October 30, 2007, 01:48:17 AM »
is this a typo??

-> NewDB.WblockCloneObjects(myObjIds., NewBT.ObjectId, myMap, DuplicateRecordCloning.Replace, False) <-- note '.' at end of myObjIds


other than that you may have to iterate the ss and add each item at a time, that's what would be happening anyway if WblockCloneObjects worked as expected.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

quamper

  • Guest
Re: Wblockclone
« Reply #2 on: October 30, 2007, 09:17:05 AM »
Yeah that was just a typo.

I found my problem was I was using NewBT.ObjectId instead of NewBTR.ObjectId in Wblockcloneobjects.

Not sure why it wasn't erroring on that.. but it's working now!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Wblockclone
« Reply #3 on: October 30, 2007, 10:15:32 AM »
quamper,
did you determine the error when you stepped through the code and investigated the value of variables ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.