TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: V-Man on June 12, 2009, 08:09:20 AM
-
How would you get in Lisp the area of a Mpolygon?
-
Marea??
What da funk is an Mpolygon??!?
-
Marea??
No such command here.
-
http://www.theswamp.org/index.php?topic=8595.0 (http://www.theswamp.org/index.php?topic=8595.0)
http://www.theswamp.org/index.php?topic=8710.0 (http://www.theswamp.org/index.php?topic=8710.0)
http://www.theswamp.org/index.php?topic=20345.0 (http://www.theswamp.org/index.php?topic=20345.0)
-
Matt W, this is it
'((-1 . <Entity name: 7ef79028>)
(0 . "MPOLYGON")
(330 . <Entity name: 7ef5fcf8>)
(5 . "D5")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbMPolygon")
(70 . 1)
(10 0.0 0.0 0.0)
(210 0.0 0.0 1.0)
(2 . "_SOLID")
(71 . 1)
(91 . 1)
(92 . 2)
(73 . 0)
(72 . 0)
(93 . 4)
(10 -40.6427 -2.83449 0.0)
(10 0.945178 -37.9821 0.0)
(10 40.6427 0.944829 0.0)
(10 2.45746 37.9821 0.0)
(76 . 1)
(63 . 256)
(11 141.553 98.8253 0.0)
(99 . 0)
(450 . 0)
(451 . 0)
(460 . 0.0)
(461 . 0.0)
(452 . 0)
(462 . 0.0)
(453 . 0)
(470 . "")
)
it's a hatched closed polyline... sort of
dvarino,
the area can be grabbed like any other area
(vla-get-Area (vlax-ename->vla-object (car (entsel))))
-
Matt W, this is it
it's a hatched closed polyline... sort of
In all my years.... never heard of that before. Huh!
-
don't worry, Matt, it's Autodesk Map custom object :)
-
Hi,
MPolygons can be imported in Vanilla from MAP if AcMPolygonObj17.dbx is loaded.
They can be created too in Vanilla with .NET or LISP using entmake.
MPolygon DXF data are similar to Hatchs ones.
(defun c:makeMPolygon (/ filename)
(setq filename (strcat "acmpolygonobj" (substr (getvar "ACADVER") 1 2) ".dbx"))
(or (member filename (arx))
(arxload filename)
)
(entmake '((0 . "MPOLYGON")
(100 . "AcDbEntity")
(100 . "AcDbMPolygon")
(70 . 1)
(10 0.0 0.0 0.0)
(210 0.0 0.0 1.0)
(2 . "ANSI31")
(71 . 0)
(91 . 2)
(92 . 2)
(73 . 0)
(72 . 0)
(93 . 5)
(10 62.6859 18.6225 0.0)
(10 120.0 60.2636 0.0)
(10 177.314 18.6225 0.0)
(10 155.422 -48.7543 0.0)
(10 84.5779 -48.7543 0.0)
(92 . 2)
(73 . 0)
(72 . 0)
(93 . 4)
(10 20.0 100.0 0.0)
(10 20.0 -100.0 0.0)
(10 220.0 -100.0 0.0)
(10 220.0 100.0 0.0)
(76 . 1)
(52 . 0.0)
(41 . 2.0)
(77 . 0)
(78 . 1)
(53 . 0.785398)
(43 . 0.0)
(44 . 0.0)
(45 . -4.49013)
(46 . 4.49013)
(79 . 0)
(11 0.0 0.0 0.0)
(99 . 0)
(450 . 0)
(451 . 0)
(460 . 0.0)
(461 . 0.0)
(452 . 0)
(462 . 0.0)
(453 . 0)
(470 . "")
)
)
(princ)
)
-
dvarino,
the area can be grabbed like any other area
(vla-get-Area (vlax-ename->vla-object (car (entsel))))
Thanks for the information.
In all my years.... never heard of that before. Huh!
Yea , me too. Very strange indeed.
-
Hi,
Here's a .NET command which allows to create a MPOLYGON in Vanilla from a selection set .
NETLOAD AcadMoplygon.dll, type PL2MPG, select entities (closed lwpolylines or 2d polylines and circles), enter the hatch pattern name (or a dot for none).
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
namespace AcadMPolygon
{
public class MpgClass : IExtensionApplication
{
public void Initialize()
{
Autodesk.AutoCAD.Runtime.SystemObjects.DynamicLinker.LoadModule("AcMPolygonObj17.dbx", false, false);
}
public void Terminate()
{
}
[CommandMethod("PL2MPG")]
public void PL2MPG()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
try
{
Database db = HostApplicationServices.WorkingDatabase;
TypedValue[] filter = { new TypedValue(-4, "<or"),
new TypedValue(0, "CIRCLE"),
new TypedValue(-4, "<and"),
new TypedValue(0, "LWPOLYLINE"),
new TypedValue(-4, "&"),
new TypedValue(70, 1),
new TypedValue(-4, "and>"),
new TypedValue(-4, "<and"),
new TypedValue(0, "POLYLINE"),
new TypedValue(-4, "&"),
new TypedValue(70, 1),
new TypedValue(-4, "<not"),
new TypedValue(-4, "&"),
new TypedValue(70, 120),
new TypedValue(-4, "not>"),
new TypedValue(-4, "and>"),
new TypedValue(-4, "or>"),
};
SelectionFilter selFilter = new SelectionFilter(filter);
PromptSelectionResult result = ed.GetSelection(selFilter);
if (result.Status == PromptStatus.OK)
{
ObjectId[] selSet = result.Value.GetObjectIds();
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
MPolygon mPolygon = new MPolygon();
foreach (ObjectId objId in selSet)
{
Entity ent = (Entity)tr.GetObject(objId, OpenMode.ForWrite);
if (ent is Polyline)
mPolygon.AppendLoopFromBoundary((Polyline)ent, true, 1E-9);
else if (ent is Circle)
mPolygon.AppendLoopFromBoundary((Circle)ent, true, 1E-9);
else
mPolygon.AppendLoopFromBoundary((Polyline2d)ent, true, 1E-9);
ent.Erase();
}
PromptStringOptions pso = new PromptStringOptions("\nEnter the hatch pattern name or a dot (.) for none: ");
pso.AllowSpaces = false;
pso.DefaultValue = (string)Application.GetSystemVariable("HPNAME");
PromptResult pr = ed.GetString(pso);
if (pr.Status == PromptStatus.OK)
{
string pat = pr.StringResult;
if (pat != ".")
{
try
{
Application.SetSystemVariable("HPNAME", pat);
mPolygon.SetPattern(HatchPatternType.PreDefined, pat);
mPolygon.PatternScale = (double)Application.GetSystemVariable("HPSCALE");
}
catch { }
}
}
mPolygon.BalanceTree();
mPolygon.BalanceDisplay();
btr.AppendEntity(mPolygon);
tr.AddNewlyCreatedDBObject(mPolygon, true);
tr.Commit();
}
}
}
catch(Autodesk.AutoCAD.Runtime.Exception ex)
{
ed.WriteMessage("Error: " + ex.Message);
}
catch (System.Exception ex)
{
ed.WriteMessage("Error: " + ex.Message);
}
}
}
}
-
A new release of PL2MPG, source code here (http://www.theswamp.org/index.php?topic=29152.msg347035#msg347035).
EDIT: Updated attached file. Now contains VanillaMPolygon_17.dll for AutoCAD 2007 to 2012 and VanillaMPolygon_19.dll for AutoCAD 2013 and later.
-
A new release of PL2MPG, source code here (http://www.theswamp.org/index.php?topic=29152.msg347035#msg347035).
It is possible to use this in autocad 2013 vanilla? I tried it, but it did't work. (My skills in .net are 0)
-
A new release of PL2MPG, source code here (http://www.theswamp.org/index.php?topic=29152.msg347035#msg347035).
It is possible to use this in autocad 2013 vanilla? I tried it, but it did't work. (My skills in .net are 0)
I updated the upper dowload: netload VanillaMPolygon_19.dll for AutoCAD 2013 or later.
-
I updated the upper dowload: netload VanillaMPolygon_19.dll for AutoCAD 2013 or later.
Thank you very much, you've been really helpful to me! And sorry for my bad english. :)
-
(xdrx-getpropertyvalue mp "area" "length")
查面积,长度