Code sample for setCoordinateSystem w/ EPSG
Dear all,
I am trying to set a coordinate system via an EPSG code to a file. When browsing the documentation I cannot find any samples or functions to do so. I have spotted
I could not identify any
Best regards
Sebastian
I am trying to set a coordinate system via an EPSG code to a file. When browsing the documentation I cannot find any samples or functions to do so. I have spotted
getEpsgCode(int &) const =0 (defined in AcDbGeoCoordinateSystem)
I could not identify any
setEpsgCode
method. Please kindly assist with a code sample (C# or C++) on how to set EPSG code to a file. Best regards
Sebastian
0
Comments
-
I found a sample here.
https://adndevblog.typepad.com/autocad/2016/04/positioning-geographicmarker-using-objectarxx.html
I have a python wrapper, but it’s not release, it works in AutoCAD, but crashes BricsCAD.
So I still need to investigate what’s going on
import traceback
from pyrx_imp import Rx
from pyrx_imp import Ge
from pyrx_imp import Gi
from pyrx_imp import Gs
from pyrx_imp import Db
from pyrx_imp import Ap
from pyrx_imp import Ed
#from pyrx_imp import Cv
# debug
def PyRxCmd_pydebug() -> None:
import PyRxDebug
PyRxDebug.startListener()
def getGeoDataId(db: Db.Database) -> Db.ObjectId:
if not Db.Core.hasGeoData(db):
data = Db.GeoData()
data.setBlockTableRecordId(db.modelSpaceId())
return data.postToDb()
return Db.Core.getGeoDataObjId(db)
def PyRxCmd_doit() -> None:
try:
db = Db.curDb()
geoCS = Db.GeoCoordinateSystem.create("UTM84-43N")
xmlStr = geoCS.getXmlRepresentation()
print(geoCS.getEpsgCode())
geoDataId = getGeoDataId(db)
if geoDataId.isNull():
return
geoData = Db.GeoData(geoDataId, Db.OpenMode.kForWrite)
geoData.setCoordinateSystem(xmlStr)
geoData.setCoordinateType(Db.GeoTypeOfCoordinates.kCoordTypLocal)
geoData.setHorizontalUnits(Db.kUnitsMillimeters)
geoData.setVerticalUnits(Db.kUnitsMillimeters)
geoData.setDesignPoint(Ge.Point3d.kOrigin)
geoData.setUpDirection(Ge.Vector3d.kZAxis)
refPtInLatLong = Ge.Point3d(78.384402, 17.434586, 0.0)
refPtInUTM84 = geoData.transformFromLonLatAlt(refPtInLatLong)
geoData.setReferencePoint(refPtInUTM84)
geoData.setNorthDirectionVector(Ge.Vector2d.kYAxis)
except Exception as err:
traceback.print_exception(err)0