Hello all
HI @david_licona
How can it be used? Command: _chspace
How much did you do about it?
I tried it but didn’t get any result
Can it be helped?
import clr
# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')
clr.AddReference('Civil3DNodes')
# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp
# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *
# Import references for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor
civdoc = CivilApplication.ActiveDocument
#XX= IN[1]
#YY= IN[2]
objects = IN[0]
def chspace(ids):
#if not hasattr(xx, "__iter__"):
#xx = [xx]
#if not hasattr(yy, "__iter__"):
#yy = [yy]
if not hasattr(ids, "__iter__"):
ids = [ids]
error_report = None
res = []
try:
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
oid=ids[0].InternalDBObject
layoutId = LayoutManager.Current
objly = t.GetObject(layoutId.GetLayoutId(layoutId.CurrentLayout), OpenMode.ForWrite)
vids = objly.GetViewports()
vids0 = t.GetObject(vids[0], OpenMode.ForWrite)
ed.SwitchToModelSpace()
command = "_chspace\n"+str(oid.Id)+"\n"
adoc.SendStringToExecute(command, True, False, False)
res.append(objly)
t.Commit()
except:
import traceback
error_report = traceback.format_exc()
if error_report is None:
return res
else:
return error_report
OUT = chspace(objects)
IN C# CODE
var ed = AcAp.DocumentManager.MdiActiveDocument.Editor;
ed.SwitchToModelSpace();
var filter = new SelectionFilter(new[] { new TypedValue(0, "MTEXT"), new TypedValue(60, 1) });
var selection = ed.SelectAll(filter);
if (selection.Status == PromptStatus.OK)
ed.Command("_chspace", selection.Value, "");
LISP
(ssadd (vlax-vla-object->ename (vlax-ename->vla-object stdd)) ss2 )
(vl-cmdf "_.chspace" ss2 "")
frame 01 ex.dwg (415.1 KB)