dxfjs / writer

A JavaScript dxf generator written in TypeScript.

Home Page:https://dxf.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ObjectARX Problem

HarshaVardhanYellanki opened this issue · comments

Could you help me out with .net objectArx ??

I would like to create a layout with 6 views in it(Top, Front, Left, Right, Bottom , Back ). The views should fit in the viewports accurately and the visual style be hidden. The views should be black in color so that i can view them when exported. Finally export the pdf.

ObjectARX code:

private static void StyleViewport(Autodesk.AutoCAD.DatabaseServices.Viewport viewport)
{
using (Database db = HostApplicationServices.WorkingDatabase)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
// "Hidden" is the name of the visual style you want
viewport.VisualStyleId = GetVisualStyleId(db, "Hidden");

// Set other properties if needed
viewport.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(0, 0, 0);

tr.Commit();
}
}
}

[CommandMethod("InsertViewsToLayout")]
public static void InsertViewsToLayout()
{
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;

using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;

BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.PaperSpace], OpenMode.ForWrite) as BlockTableRecord;

// Switch to the previous Paper space layout
Application.SetSystemVariable("TILEMODE", 0);
acDoc.Editor.SwitchToPaperSpace();

// Get the current layout
LayoutManager acLayoutMgr = LayoutManager.Current;
Layout acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), OpenMode.ForWrite) as Layout;

Point3d[] viewPositions = {
new Point3d(2.5, 5.5, 0),
new Point3d(2.5, 2.5, 0),
new Point3d(5.5, 5.5, 0),
new Point3d(5.5, 2.5, 0),
new Point3d(8.5, 5.5, 0),
new Point3d(8.5, 2.5, 0)
};

Vector3d[] viewDirections = {
new Vector3d(0, 0, -1),
new Vector3d(0, 0, 1),
new Vector3d(-1, 0, 0),
new Vector3d(1, 0, 0),
new Vector3d(0, -1, 0),
new Vector3d(0, 1, 0)
};

for (int i = 0; i < viewPositions.Length; i++)
{
using (Autodesk.AutoCAD.DatabaseServices.Viewport acVport = new Autodesk.AutoCAD.DatabaseServices.Viewport())
{
acVport.CenterPoint = viewPositions[i];
acVport.Width = 2.5;
acVport.Height = 2.5;

// Add the new viewport to the layout's block table record
acBlkTblRec.AppendEntity(acVport);
acTrans.AddNewlyCreatedDBObject(acVport, true);

// Set the view direction
acVport.ViewDirection = viewDirections[i];

// Set the visual style
StyleViewport(acVport);

// Enable the viewport
acVport.On = true;
}
}

acTrans.Commit();
acDoc.Editor.Regen();
}
}

Here's my code:
Error is :
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'GetVisualStyleId' does not exist in the current context AutoCad C:\Users\source\repos\AutoCad\AutoCad\Commands.cs 268 Active

i am trying a lot but unable to figure out the solution.
Please resolve my issue.

You can also modify approach of viewports, You can insert views using "Base->Model Space" that way...

Hi,

I am sorry, I never used the ObjectARX SDK, so I can't help you.

Regads.