I want to modify the properties of a raster so that the coordinate system of the model is inherited. The VBA crashes at the statement setvalue.
I get the error message illegal operation for this type (runtime error -2147220778 (800402d6)).Is this not allowed ? and then how should it be done?
Public Sub RasterInheritGCS(oRaster As raster, bInheritGCSFromModel As Boolean) If TypeName(oRaster) <> "Raster" Then Exit Sub Dim sAccessStringNameToGet As String sAccessStringNameToGet = Replace(Trim("Geocoding.GCSInherited"), " ", "") Debug.Print sAccessStringNameToGet Dim oEl As Element Set oEl = RasterManager.Rasters.GetElementFromRaster(oRaster) Dim oPH As PropertyHandler Set oPH = CreatePropertyHandler(oEl) Dim sGCSInheritedbefore As String Dim sGCSInheritedafter As String sGCSInheritedafter = "Inherited" Debug.Print oRaster.RasterInformation.FileNameExploded If oPH.SelectByAccessString(sAccessStringNameToGet) Then Debug.Print "after" & sGCSInheritedafter sGCSInheritedbefore = oPH.GetValue Debug.Print "before" & sGCSInheritedbefore If sGCSInheritedbefore <> sGCSInheritedafter Then oPH.setValue ("Inherited") End If End Sub
regards Corina
Hi Corina,
please be aware this is general Developer and Programming forum, but other, product-specific programming forum exists.
Follow the best practices and please specify, what product and (exact) version you use. Depending on the product used, use More > Move tool (available under your original post) to move this discussion e.g. to MicroStation Programming forum (when applicable).
Also, please edit your original question and to post VBA snippet using Insert > Insert code tool. Code as not formatted plain text is not readable and cannot be analyzed.
Is it possible to share example, how raster is attached? E.g. empty DGN file with some raster, attached exactly in the same way, is enough. There are plenty of options, how raster can be attached, so to make exactly what setting and in what context is modified can be crucial.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point