Using wblockCloneObjects + dimensions

Using wblockCloneObjects + dimensions

Anonymous
Not applicable
650 Views
7 Replies
Message 1 of 8

Using wblockCloneObjects + dimensions

Anonymous
Not applicable
I'm trying to use AcDbDatabase::wblockCloneObjects to copy some entities from one drawing to another. This seems to work fine as long as the entities being copied are not dimensions. The dimensions get copied, but for whatever reason they aren't ever displayed. I can get around this problem by using AcDbDatbase::insert(), but i'm dealing with a specific set of entities. I could get around THAT problem by simply using wblock, and THEN insert - but with large drawings i'm noticing that having to do two steps like that is slowing things down. So is there something special you have to do with dimensions to get them to show up, or do i need to use those other functions? Here's basically what i'm doing. In the actual code i'm using, i check error status on every single statement - nothing returns any errors, and everything but dimensions are displayed fine after the copy. It all looks just as it does in the original file. // The databases to use are sent in. // pSourceDb is an external DWG file that was opened using readDwgFile. // pDestDb is (in this case) the current document. // Get the model space id for source and destination databases AcDbObjectId idSrc, idDest; idSrc = GetModelSpaceId(pSourceDb); idDest = GetModelSpaceId(pDestDb); // Build a list of entities that need to be copied AcDbObjectIdArray idsToCopy; // Get entities here. Use idSrc to open block record // and choose the ents we need. (left out for brevity) AcDbIdMapping idMap; idMap.setDestDb(pDestDb); pSource->wblockCloneObjects(idsToCopy, idDest, idMap, AcDb::kDrcIgnore); Are there more steps i need to add for dimensions?
0 Likes
651 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
I get the same results with wblockCloneObjects() and dimensions. They are cloned but they don't display until they are moved (via 'all' selection). Perhaps this is a bug? -- Best regards, Byron Blattel CADwerx--Applications for AutoCAD Autodesk Registered Developer Contact Info @ http://www.cadwerx.net Custom Programming Services - ObjectARX/C++/MFC/ASP/STL/ATL/ISAPI...
0 Likes
Message 3 of 8

Anonymous
Not applicable
Well, thanks for the response. I'll try out the move thing. It's ONLY with 'all'? Have you tried programatically transforming them, or it's only when the user issues the move command? "Byron Blattel" wrote in message news:4070d863$1_1@newsprd01... > I get the same results with wblockCloneObjects() and dimensions. They > are cloned but they don't display until they are moved (via 'all' > selection). > > Perhaps this is a bug? > > -- > Best regards, > > Byron Blattel > CADwerx--Applications for AutoCAD > Autodesk Registered Developer > Contact Info @ http://www.cadwerx.net > Custom Programming Services - ObjectARX/C++/MFC/ASP/STL/ATL/ISAPI...
0 Likes
Message 4 of 8

Anonymous
Not applicable
Are these dimensions on a layer that is not already present in the target drawing? I ask because if the target drawing is loaded in the AutoCAD editor, then it has a layer cache that is used to keep track of layer status in order to determine what should be displayed, and wblockCloneObjects() doesn't update this layer cache for the target drawing, so entities that are cloned and reside on a layer that is also cloned won't show up in the target drawing until the layer cache is updated. "Justavian" wrote in message news:406d7b0a$1_2@newsprd01... > I'm trying to use AcDbDatabase::wblockCloneObjects to copy some entities > from one drawing to another. This seems to work fine as long as the > entities being copied are not dimensions. The dimensions get copied, but > for whatever reason they aren't ever displayed. I can get around this > problem by using AcDbDatbase::insert(), but i'm dealing with a specific set > of entities. I could get around THAT problem by simply using wblock, and > THEN insert - but with large drawings i'm noticing that having to do two > steps like that is slowing things down. So is there something special you > have to do with dimensions to get them to show up, or do i need to use those > other functions? > > Here's basically what i'm doing. In the actual code i'm using, i check > error status on every single statement - nothing returns any errors, and > everything but dimensions are displayed fine after the copy. It all looks > just as it does in the original file. > > > > // The databases to use are sent in. > // pSourceDb is an external DWG file that was opened using readDwgFile. > // pDestDb is (in this case) the current document. > > // Get the model space id for source and destination databases > AcDbObjectId idSrc, idDest; > idSrc = GetModelSpaceId(pSourceDb); > idDest = GetModelSpaceId(pDestDb); > > > // Build a list of entities that need to be copied > AcDbObjectIdArray idsToCopy; > // Get entities here. Use idSrc to open block record > // and choose the ents we need. (left out for brevity) > > > AcDbIdMapping idMap; > idMap.setDestDb(pDestDb); > > > pSource->wblockCloneObjects(idsToCopy, idDest, idMap, AcDb::kDrcIgnore); > > > > Are there more steps i need to add for dimensions? > >
0 Likes
Message 5 of 8

Anonymous
Not applicable
You are correct in assuming that the dimensions' layer is not yet present in the drawing. However, i'm not sure why dimensions aren't working, since the rest of the entities (also on layers not present in the destination drawing) show up fine. I've also attempted to clone over the layers first, but that didn't seem to help. How do i update the layer cache? I'm not familiar with this term. "Art Cooney" wrote in message news:4072d465_3@newsprd01... > Are these dimensions on a layer that is not already present in the target > drawing? I ask because if the target drawing is loaded in the AutoCAD > editor, then it has a layer cache that is used to keep track of layer status > in order to determine what should be displayed, and wblockCloneObjects() > doesn't update this layer cache for the target drawing, so entities that are > cloned and reside on a layer that is also cloned won't show up in the target > drawing until the layer cache is updated. > > "Justavian" wrote in message > news:406d7b0a$1_2@newsprd01... > > I'm trying to use AcDbDatabase::wblockCloneObjects to copy some entities > > from one drawing to another. This seems to work fine as long as the > > entities being copied are not dimensions. The dimensions get copied, but > > for whatever reason they aren't ever displayed. I can get around this > > problem by using AcDbDatbase::insert(), but i'm dealing with a specific > set > > of entities. I could get around THAT problem by simply using wblock, and > > THEN insert - but with large drawings i'm noticing that having to do two > > steps like that is slowing things down. So is there something special you > > have to do with dimensions to get them to show up, or do i need to use > those > > other functions? > > > > Here's basically what i'm doing. In the actual code i'm using, i check > > error status on every single statement - nothing returns any errors, and > > everything but dimensions are displayed fine after the copy. It all looks > > just as it does in the original file. > > > > > > > > // The databases to use are sent in. > > // pSourceDb is an external DWG file that was opened using readDwgFile. > > // pDestDb is (in this case) the current document. > > > > // Get the model space id for source and destination databases > > AcDbObjectId idSrc, idDest; > > idSrc = GetModelSpaceId(pSourceDb); > > idDest = GetModelSpaceId(pDestDb); > > > > > > // Build a list of entities that need to be copied > > AcDbObjectIdArray idsToCopy; > > // Get entities here. Use idSrc to open block record > > // and choose the ents we need. (left out for brevity) > > > > > > AcDbIdMapping idMap; > > idMap.setDestDb(pDestDb); > > > > > > pSource->wblockCloneObjects(idsToCopy, idDest, idMap, AcDb::kDrcIgnore); > > > > > > > > Are there more steps i need to add for dimensions? > > > > > >
0 Likes
Message 6 of 8

Anonymous
Not applicable
Art Cooney wrote: > Are these dimensions on a layer that is not already present in the target > drawing? I ask because if the target drawing is loaded in the AutoCAD > editor, then it has a layer cache that is used to keep track of layer status > in order to determine what should be displayed, and wblockCloneObjects() > doesn't update this layer cache for the target drawing, so entities that are > cloned and reside on a layer that is also cloned won't show up in the target > drawing until the layer cache is updated. In my case the layer does not pre-exist... Is there a way to update the layer cache? applyCurDwgLayerTableChanges() perhaps? -- Best regards, Byron Blattel CADwerx--Applications for AutoCAD Autodesk Registered Developer Contact Info @ http://www.cadwerx.net Custom Programming Services - ObjectARX/C++/MFC/ASP/STL/ATL/ISAPI...
0 Likes
Message 7 of 8

Anonymous
Not applicable
This response answers both Justavian and Byron: As a test to see if this really is the problem, when your code has finished and the target drawing is the active document in AutoCAD, simply click on the layer toolbar to open it and then click it again to close it. You don't have to do anything to any layers. This will force the layer cache to be udpated in AutoCAD. If that causes the dimension to display, then the problem is indeed the layer cache being out of date. If that doesn't cause the the dimension to display, then something else is going on. If the layer cache is the problem, then one way to force the layer cache to update is to entmod a layerTableRecord to change its state in one of the following ways: on/off freeze/thaw lock/unlock change linetype objectId VPDFLT state The least intrusive of these would be to change the lock state. You'd want to do two entmods in order to end up with the layer state back the way it was, but in the process the layer cache will be updated. "Justavian" wrote in message news:4072e1ec$1_2@newsprd01... > You are correct in assuming that the dimensions' layer is not yet present in > the drawing. However, i'm not sure why dimensions aren't working, since the > rest of the entities (also on layers not present in the destination drawing) > show up fine. I've also attempted to clone over the layers first, but that > didn't seem to help. > > How do i update the layer cache? I'm not familiar with this term. > > > > "Art Cooney" wrote in message > news:4072d465_3@newsprd01... > > Are these dimensions on a layer that is not already present in the target > > drawing? I ask because if the target drawing is loaded in the AutoCAD > > editor, then it has a layer cache that is used to keep track of layer > status > > in order to determine what should be displayed, and wblockCloneObjects() > > doesn't update this layer cache for the target drawing, so entities that > are > > cloned and reside on a layer that is also cloned won't show up in the > target > > drawing until the layer cache is updated. > > > > "Justavian" wrote in message > > news:406d7b0a$1_2@newsprd01... > > > I'm trying to use AcDbDatabase::wblockCloneObjects to copy some entities > > > from one drawing to another. This seems to work fine as long as the > > > entities being copied are not dimensions. The dimensions get copied, > but > > > for whatever reason they aren't ever displayed. I can get around this > > > problem by using AcDbDatbase::insert(), but i'm dealing with a specific > > set > > > of entities. I could get around THAT problem by simply using wblock, > and > > > THEN insert - but with large drawings i'm noticing that having to do two > > > steps like that is slowing things down. So is there something special > you > > > have to do with dimensions to get them to show up, or do i need to use > > those > > > other functions? > > > > > > Here's basically what i'm doing. In the actual code i'm using, i check > > > error status on every single statement - nothing returns any errors, and > > > everything but dimensions are displayed fine after the copy. It all > looks > > > just as it does in the original file. > > > > > > > > > > > > // The databases to use are sent in. > > > // pSourceDb is an external DWG file that was opened using readDwgFile. > > > // pDestDb is (in this case) the current document. > > > > > > // Get the model space id for source and destination databases > > > AcDbObjectId idSrc, idDest; > > > idSrc = GetModelSpaceId(pSourceDb); > > > idDest = GetModelSpaceId(pDestDb); > > > > > > > > > // Build a list of entities that need to be copied > > > AcDbObjectIdArray idsToCopy; > > > // Get entities here. Use idSrc to open block record > > > // and choose the ents we need. (left out for brevity) > > > > > > > > > AcDbIdMapping idMap; > > > idMap.setDestDb(pDestDb); > > > > > > > > > pSource->wblockCloneObjects(idsToCopy, idDest, idMap, AcDb::kDrcIgnore); > > > > > > > > > > > > Are there more steps i need to add for dimensions? > > > > > > > > > > > >
0 Likes
Message 8 of 8

Anonymous
Not applicable
Art Cooney wrote: > This response answers both Justavian and Byron: > > As a test to see if this really is the problem, when your code has finished > and the target drawing is the active document in AutoCAD, simply click on > the layer toolbar to open it and then click it again to close it. You don't > have to do anything to any layers. This will force the layer cache to be > udpated in AutoCAD. If that causes the dimension to display, then the > problem is indeed the layer cache being out of date. If that doesn't cause > the the dimension to display, then something else is going on. It would appear that the problem is elsewhere then. Opening the layer manager has no effect for me. Neither does changing the properties of the associated layer (lock, on/off, etc.) applyCurDwgLayerTableChanges() also does not work. If I iterate the cloned dimensions and call recordGraphicsModified() on them they show up properly... -- Best regards, Byron Blattel CADwerx--Applications for AutoCAD Autodesk Registered Developer Contact Info @ http://www.cadwerx.net Custom Programming Services - ObjectARX/C++/MFC/ASP/STL/ATL/ISAPI...
0 Likes