My goal is to batch plots using VB in Visual Studio 2008, Autocad Map 3D 2010, Win 7 Pro 64. It all works but now I want to apply layerstates.
I am using the example in the dev. guide here: http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html
My questions: (any answers or advice is appreciated)
1. If you use Option Strict, how do you convert from integer to "layerstatesmasks.color"? VS shows the error "Option Strict On disallows implicit conversions from 'Integer' to 'Autodesk.AutoCAD.DatabaseServices.LayerStateMasks'." I can't figure out the conversion. Are the values documented somewhere? "clientmask" is not in the object browser or the dev. guide.
2. If you aren't sure what is masked, do you turn on all of the options on (on, color, linetype, lineweight, etc.)? Is there a sum of values that means "layerstatemasks.all"?
3. LAS files are DXF format. Do I have to read the LAS to detemine what the user wants?
4. The second argument to .restorelayerstate is the viewport id. The examples use objectid.null. I could have several layouts to plot, and maybe several viewports. Is the process a) Make the layout current, b) activate each viewport, c) set model space current, and d) restore the layerstate?
1. If you use Option Strict, how do you convert from integer to "layerstatesmasks.color"? VS shows the error "Option Strict On disallows implicit conversions from 'Integer' to 'Autodesk.AutoCAD.DatabaseServices.LayerStateMasks'." I can't figure out the conversion. Are the values documented somewhere? "clientmask" is not in the object browser or the dev. guide.
The LayerStateMask is an enum and is defined like this:
[Wrapper("AcDbLayerStateManager::LayerStateMask"), Flags]
public enum LayerStateMasks
{
Color = 0x20,
CurrentViewport = 0x200,
Frozen = 2,
LastRestored = 0x10000,
LineType = 0x40,
LineWeight = 0x80,
Locked = 4,
NewViewport = 0x10,
None = 0,
On = 1,
Plot = 8,
PlotStyle = 0x100
}
Its a wrapper for the C++ based enum. Having said that, I do see some differences between the C++ and .NET enum though. The C++ enum has the following additional enums defined:
kAll = kOn|kFrozen|kLocked|kPlot|kNewViewport|kColor|kLineType|kLineWeight|kPlotStyle|kCurrentViewport,
kStateIsHidden = 0x8000,
kDecomposition = kAll|0x20000
They are all integers so you could just use a standard explicit cast in your VB .NET code:
CType(LayerStateMasks.Color, Integer)
2. If you aren't sure what is masked, do you turn on all of the options on (on, color, linetype, lineweight, etc.)? Is there a sum of values that means "layerstatemasks.all"?
Since the .NET enum does not have an equavalent of kAll, you could do it yourself as shown above in kAll.
3. LAS files are DXF format. Do I have to read the LAS to detemine what the user wants?
I am assuming here your talking about Layer State Files and not LIDAR point cloud files that are also supported by Map 3D. If so, you could just import the LAS files: http://docs.autodesk.com/ACD/2011/ENU/filesAUG/WS1a9193826455f5ffb9242e10d8082106b-7fe4.htm
Or use the LayerStateManager.ImportLayerState method.
4. The second argument to .restorelayerstate is the viewport id. The examples use objectid.null. I could have several layouts to plot, and maybe several viewports. Is the process a) Make the layout current, b) activate each viewport, c) set model space current, and d) restore the layerstate?
You dont really have to switch between model/paper spaces. As long as you have the ObjectID of the viewport, you can just call the RestoreLayerState method with that objectID.
Hope this helps.
Gopinath Taget
Autodesk Developer Network
Thanks for the reply. When you say the .NET enum I assume you are looking at the latest API? I am asking because I have access to acad map 2012 but have not used those references yet.
The explicit cast ctype(layerstatemasks.color, integer) generates the "option strict on disallows implicit conversions" error. That's confusing. It seems as if the cast needs to go the other way - as in ctype(myinteger, layerstatesmasks.color), or ctype(myinteger, layerstatemasks). But, those generate a "type not defined" error.
I think I need an integer equivalent for kAll. Is there a way to reference or include the C++ wrapper?