Quantcast
Channel: Autodesk India Community aggregator
Viewing all 1680 articles
Browse latest View live

AutoCAD Customization: .NET: Acad P&ID - Iterate through all model spaces of project drawings

$
0
0

Hello everyone,

 

I hope someone can help me with this. I'm writing a self made command for Autocad P&ID 2014 in C#. With this method, I want to search for a tag in my project and draw a circle around it. At the moment, I can give in my self made command, named 'GETTAG', give in a tagvalue in the editor and then my self made command searches for this tag in the modelspace of the 'MdiActiveDocument'. If the tag is found, a circle is drawn around the tag. This is achieved by searching the BlockTableRecord of the ModelSpace of the current drawing.

 

editor = AcadApp.DocumentManager.MdiActiveDocument.Editor;
DB = AcadApp.DocumentManager.MdiActiveDocument.Database;

 

trans.TransactionManager transActionManager = DB.TransactionManager;
            using (Transaction transAction = transActionManager.StartTransaction())
            {
                BlockTable blockTable = (BlockTable)transAction.GetObject(DB.BlockTableId, OpenMode.ForRead);
                BlockTableRecord blockTableRecord = (BlockTableRecord)transAction.GetObject(blockTable["*Model_Space"], OpenMode.ForRead);

                // An P&Id object is a Linesegment or an Asset
                BlockTableRecordEnumerator iter = blockTableRecord.GetEnumerator();
                while (iter.MoveNext())
                {
                    DBObject dbObject = transAction.GetObject(iter.Current, OpenMode.ForRead);

                    LineSegment lineSegm = dbObject as LineSegment;
                    if (lineSegm != null)
                    {
                        if (lineSegm.TagValue == tagName)
                        {
                            strMsg = "\nLinesegment with tagvalue: " + lineSegm.TagValue + " is from class: " + lineSegm.ClassName;
                            editor.WriteMessage(strMsg);
                        }
                    }

                    Asset asset = dbObject as Asset;
                    if (asset != null)
                    {
                        if (asset.TagValue == tagName)
                        {
                            strMsg = "\nAsset with tagvalue: " + asset.TagValue + " is from class: " + asset.ClassName;
                            editor.WriteMessage(strMsg);
                        }
                    }
                }

 

But what if I give in a tagvalue, that is placed on a other drawing then the active drawing? Then my method has to check every drawing which belong to the project and then, if the tag is found, my method has to open this drawing and then draw a circle around the tag.

 

My big question is, how do I iterate trough all the drawings of my project (whitout opening the drawings) and search for the correct tag? Can I acces the modelspaces of the drawings without opening the drawings (with Documentmanager.Open())

 

If someone can help me, please let me know.

 

Regards


AutoCAD Customization: Autodesk ObjectARX: How to Create the FrameWnd derived from the CFrameWnd class

$
0
0

Hi ! Everyone!

 

If some one knows, Please help me.

 

I'm beening develop ARX program on the AutoCAD 2013 64 bit environment, Using the VS2010.

But, I encounterd big problems to create the Framewnd.

 

Below code worked AutoCAD2010 and VS2008 environment.

//---------------------------------------------------------------------------

CAcModuleResourceOverride resOverride;

dataFactory.pFrame = new CMainFrame;

RECT CRect = {x, y, 0, 0};

if (!dataFactory.pFrame->Create(_T("Test Wnd!"),
 WS_VISIBLE | WS_OVERLAPPEDWINDOW, CRect, NULL))
 acutPrintf(_T("Error: Failed to create the Window!"));

dataFactory.pFrame->MoveWindow (x, y, 300, 195);
dataFactory.pFrame->m_flg = TRUE;
acedGetAcadFrame()->SetFocus();

//----------------------------------------------------------------------------

The dataFactory class where restored some pointers and variables

Aboved code did not work on the 2013 and VS2010.

 

dataFactory.pFrame->MoveWindow (x, y, 300, 195); is crashed.

The Wnd pointer must be exist, It is not NULL.

 

Where am I wrong??

Please help me!!!!

 

AutoCAD Customization: .NET: problem with constructor

$
0
0

I want to inform user the name of command immediately when they netload my dll. I use the constructor like this way:

 

public class Control
    {
        public Control()
        {
            Editor acDoc = Application.DocumentManager.MdiActiveDocument.Editor;
            acDoc.WriteMessage("Type ABC to start");
        }

        [CommandMethod("abc", CommandFlags.UsePickSet)]
        public void MyForm_start()
        {
            MyForm fr = new MyForm();
            Application.ShowModalDialog(fr);
        }

    }

 

But it only write to command line when call abc command. Pls help!

AutoCAD Customization: Autodesk ObjectARX: AcDbPolyline displayed incorrectly when using setLineTypeScale

$
0
0

Hello.

 

I have a linetype, which consists of two parallel straight lines. This linetype is loaded through shp and lin files. Some lines of a drawing of type AcDbPolyline use this linetype. There is also a regenerating procedure, which rescales linetype, for the screen distance between two straights of the linetype to be 1 mm, after any change of view scale. This procedure uses setLineTypeScale. Parameter for this method is calculated depending on the view scale.

 

When the drawing is generated first, lines that use that linetype look correctly. When I change the view scale, using the mouse wheel, screen width between the starights of the linetype changes accordingly, but this is ok. When then the drawing is rgenerated by my procedure, the linetype is rescaled, and the screen width between the linetype straight gets 1 mm again, and that is intended and ok. Until now everything is fine. When the drawing is scaled by its borders, the linetype scaling coefficient is about 400.

 

Then I add a raster image (jpg) on the drawing. At the end of this, lines of this linetype lose there screen wdth, and look incorrectly. The linetype scaling coefficient at this time remains the same, 400. On regenerating, the procedure repeats setting 400. The view scale remain the same. But the line size is lost. To get the screen width of the line 1 mm again, I have to put linetype scale about 2.  Width of the line was 0 and is not changed.

 

So I came to a conclusion that screen size of a line depends not only on linetype scale. There might be some other parameter.  What is that parameter, and how to get it using ObjectARX? I should have rescaled the linetype with 2 and not 400, but I don't know what has changed to take it into account.

 

Or there might be some other way to use two-starights linetype, with 1 mm distance on the screen for any view scale?

 

AutoCAD is 2010.3

 

Thanks in advance.

 

View scale is calculated this way:

double GetViewScale()
{
   resbuf viewsize;   acedGetVar(L"viewsize",&viewsize);
   resbuf screensize; acedGetVar(L"screensize",&screensize);
      
   double height = viewsize.resval.rreal;
   double screenheight = screensize.resval.rpoint[Y];
   
   return height/screenheight;
}

 

The linetype is constructed this way:

// in .shp file
*216,15,RRS
1,3,50,020,2,028,4,35,02C,3,35,028,1,070,0

// in .lin file
A,0.00000001,[RRS,mylin.shx,S=1.6],0.22,0.00000001 

 

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: lisp function as macro?

$
0
0

I use the following lisp to navigate through my toolpalettes

 

(command "*_TOOLPALETTEPATH" "C:/path/to/My/atc/file")

Is it however possible to do this using a macro instead?

 

Thanks-

AutoCAD Customization: .NET: stretch block dynamic grips

$
0
0

Hi,

 

I have a problem with dynamic blocks.

I have inserted a dynamic block (with .NET) and changed the value of a dynamic parameter (Linear). The block is stretched as it should be. (no problems here).

 

After a fiew other routines, I select the block again (by using its objectID) and a want to get the coördinates of the grip of the linear dynamic paramter. Is there a way to get the coördinates based on the linear dynamic parameter and its grip points? Can someone help me wit a pease of code in vb.Net?

 

thx

 

Filip

AutoCAD Customization: .NET: PromptEntityOptions Help

$
0
0

Hi, I am not sure how to do this.  I need to prompt for entity selection. Also, I want the procedure to use a default value, but to give the user a chance to change the initial or default value. So, I thought to use Keywords.  I want to prompt the user with something like this "Please select a block or [Set value] <30>:" The problem I have is that if I set a default value it has to be included on the keywords collection.  I prefer not to have default value shown as a keyword.  I tried to use the visible property of the keyword item, but it will crash AutoCAD.  Can someone help me to make this work. Thank you in advance.

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Help for selecting multiple objects to export their coordinates and ID

$
0
0

Hi Sirs

I am just starting learning lisp, And I am looking for a fast way to select multiple objects (usually circle) and export their coordinates and ID into a excel sheet through lisp programming.

As you might see in the attached drawing, the red circles are objects wanted. I have been trying to export their coordinates as well as their IDs in grids, e.g D28, Easting:  Northing:  . I still haven't found a good way to export ID for each circle.

As my code doesn't work, I wonder what's the most effective way to detect errors in lisp

Thx

Ji

 

 


AutoCAD Customization: .NET: Passinga Structure to a Sub

$
0
0

Hello, I have a need to save coordinates points for a couple of objects, so I decided to use a structure object.

Here is my structure for an 8 sided polygon:

 Structure OctoPolygon
        Public Shared pt1 As New Geometry.Point3d
        Public Shared pt2 As New Geometry.Point3d
        Public Shared pt3 As New Geometry.Point3d
        Public Shared pt4 As New Geometry.Point3d
        Public Shared pt5 As New Geometry.Point3d
        Public Shared pt6 As New Geometry.Point3d
        Public Shared pt7 As New Geometry.Point3d
        Public Shared pt8 As New Geometry.Point3d

        Public Sub setPoints(ByVal drawingStartPoint As Double, ByVal mcSize As Double, ByVal mcCenter2Cham As Double)
            Dim mcX1neg As Double, mcX2neg As Double, mcX1pos As Double, mcX2pos As Double
            Dim mcY1neg As Double, mcY2neg As Double, mcY1pos As Double, mcY2pos As Double
            Dim mcChamLength As Double

            ' Set the moldcap chamfer value
            mcChamLength = ((mcSize / 2) - mcCenter2Cham)

            ' Set the new corners based on length and chamfer of the polygon
            mcX1neg = drawingStartPoint - (mcSize / 2)
            mcX2neg = drawingStartPoint - ((mcSize / 2) - mcChamLength)
            mcX1pos = drawingStartPoint + (mcSize / 2)
            mcX2pos = drawingStartPoint + ((mcSize / 2) - mcChamLength)
            mcY1neg = ((mcSize / 2) * -1)
            mcY2neg = (((mcSize / 2) - mcChamLength) * -1)
            mcY1pos = (mcSize / 2)
            mcY2pos = ((mcSize / 2) - mcChamLength)

            pt1 = New Geometry.Point3d(mcX1neg, mcY2neg, 0)
            pt2 = New Geometry.Point3d(mcX2neg, mcY1neg, 0)
            pt3 = New Geometry.Point3d(mcX2pos, mcY1neg, 0)
            pt4 = New Geometry.Point3d(mcX1pos, mcY2neg, 0)
            pt5 = New Geometry.Point3d(mcX1pos, mcY2pos, 0)
            pt6 = New Geometry.Point3d(mcX2pos, mcY1pos, 0)
            pt7 = New Geometry.Point3d(mcX2neg, mcY1pos, 0)
            pt8 = New Geometry.Point3d(mcX1neg, mcY2pos, 0)
        End Sub

    End Structure

Then I want to send that object to a sub that will draw the octagonal polyline:

' Create octagonal moldcap shapes
    Public Sub addPolyOctagon(ByVal polyStruct As OctoPolygon)
        Dim podPolyOctagonTransMan As DatabaseServices.TransactionManager
        Dim podPolyOctagonTrans As DatabaseServices.Transaction
        Dim podDWG As ApplicationServices.Document
        Dim podBT As DatabaseServices.BlockTable
        Dim podBTR As DatabaseServices.BlockTableRecord

        ' Get the active document and begin a Transaction
        podDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
        podPolyOctagonTransMan = podDWG.TransactionManager
        podPolyOctagonTrans = podPolyOctagonTransMan.StartTransaction

        ' Open the BlockTable for Read
        podBT = podDWG.Database.BlockTableId.GetObject(DatabaseServices.OpenMode.ForRead)
        podBTR = podBT(DatabaseServices.BlockTableRecord.ModelSpace).GetObject(DatabaseServices.OpenMode.ForWrite)

        ' Draw the polyline
        Dim polyCorners As New Autodesk.AutoCAD.Geometry.Point3dCollection
        polyCorners.Add(New Geometry.Point3d(polyStruct.pt1))
        polyCorners.Add(New Geometry.Point3d(polyStruct.pt2))
        polyCorners.Add(New Geometry.Point3d(polyStruct.pt3))
        polyCorners.Add(New Geometry.Point3d(polyStruct.pt4))
        polyCorners.Add(New Geometry.Point3d(polyStruct.pt5))
        polyCorners.Add(New Geometry.Point3d(polyStruct.pt6))
        polyCorners.Add(New Geometry.Point3d(polyStruct.pt7))
        polyCorners.Add(New Geometry.Point3d(polyStruct.pt8))
        Dim mcPLine As New DatabaseServices.Polyline2d(DatabaseServices.Poly2dType.SimplePoly, _
        polyCorners, 0, True, 0, 0, Nothing)
        podBTR.AppendEntity(mcPLine)
        podPolyOctagonTrans.AddNewlyCreatedDBObject(mcPLine, True)

        ' Commit the Transaction
        podPolyOctagonTrans.Commit()
        podPolyOctagonTrans.Dispose()
        podPolyOctagonTransMan.Dispose()

    End Sub

 It's having a real problem with the lines:

polyCorners.Add(New Geometry.Point3d(polyStruct.pt1))

It says "Access of shared member, constant member, enum member, or nested type through an instance; qualifying expression wil not be evaluated"

 

Can someone please explain the to me, and tell me how I can get the sub to see the points defined in the structure?

 

Thanks,

Mark

AutoCAD Customization: .NET: APPCRASH error when exiting RealDWG WinForms App

$
0
0

I have developed a C# winforms app with RealDWG SDK. When I close my form I get the "App has stopped working" error below.

 

I've added in some Dispose methods to see if that was the issue, but I still get the error.

I added a dispose method to my HostApplication class and I called my Winform dispose method.

I thought that the error was caused by unfinished RealDWG business at the Form Closing event.

 

I am using RealDWG 2013, Visual Studio 2010 SP1, Windows 7 64-bit.

I also have AutoCAD 2012 and 2013 installed.

I know that AutoCAD and RealDWG both use acdb19.dll.

 

My app contains 6 classes with around 1000 lines of code on each class, so to paste in my code would be impossible. Here is my code structure.

 

I start by implementing a HostApplicationService Class (MyHost.cs)

Then I call my Windows Form. (MainForm.cs)

From my form I collect object data from a SqlDatabase.

Once the data is aquired, I send the data to a Class that handles my AutoCAD classes. (AutoCAD.cs)

In this class I create my RealDWG Database.

Next I pass the database to various IDisposable classes that perform AutoCAD actions.

I.E, CreateTitleBlock() CreateLayers(), DrawShape(); etc..

 

Everything works great, except when I go to close the app, I get the error.

I dispose everything I can think of right before exiting.

 

I've tried

this.Close();

Application.Exit();

 

Any ideas on how to dispose the app or close it cleanly?

 

Thanks,

Eric

 

Here is the error....

 

Problem signature:

  Problem Event Name: APPCRASH

  Application Name: LongBayRD.exe

  Application Version: 1.0.0.0

  Application Timestamp: 519fa185

  Fault Module Name: acdb19.dll

  Fault Module Version: 19.0.55.0

Fault Module Timestamp: 4f309c70

  Exception Code: c0000005

  Exception Offset: 0000000000058166

 

AutoCAD Customization: .NET: How to implement Drop-down list (based on IDynamicEnumProperty) in OPM?

$
0
0

Hi!

Is there somone who can explain/show a sample of how a custom drop-down list in OPM can be implemented? Based on some articels by Kean Walmsley, I have successfully implemented categorized properties in the OPM using a .NET wrapper and C#. I have a class imlementing the members of the IDynamicEnumProperty, ICategorizeProperties and IDynamicProperty2 interfaces (based on ObjectARX 2013).

 

However, I do not really understand how to code custom drop-down list using .NET wrapper and OPM. I am using AutoCAD 2013 and 2014. I have read a lot of posts regarding OPM but there was no helpful information in regards to create custom drop-down lists. I will greatly appreciate any help showing how to achieve that or giving a link to more details.

 

AutoCAD Customization: .NET: Reading XREF tree from external exe

$
0
0

Hi all,

I am trying to read the xref tree from a DWG by using an external exe. The app should simply open the DWG and sys-out the referenced paths and whether or not they are nested.
For this, I am using Autodesk.AutoCAD.Interop.
The problem is that I can only get a list of file dependencies (document.FileDependencies) and I can't seem to find an "isNested" value.
Is this even possible?

So far I've got:

AcadDocument document = oAcadApp.Documents.Open("Test.dwg");
foreach (AcadFileDependency o in document.FileDependencies)
{
 System.Console.Out.WriteLine(o.FullFileName);
}

There is also the option to get Blocks, but again there is no "isNested" info, only "isXref":
foreach (AcadBlock b in document.Database.Blocks)
                {
                    if (b.IsXRef)
                    {
                        ...doStuff...
                    }
                }

Any help would be very appreciated :)

AutoCAD Customization: .NET: Identifying Object Type String for Selection Set Filter

$
0
0

I am currently running AutoCAD 2011. I have a specific problem, but I am also looking for a solution to the general issue as well.

 

Specifically, I am trying to identify the object type of a Polyface Mesh for use in a Selection Set filter. For example, a 3D solid will return "Solid3D" from the GetType method, but for the selection set filter I have to use the string "3DSOLID" in order for it to filter correctly. The GetType method for my Polyface Mesh returns PolyFaceMesh, which does not work for my Selection Set filter.

 

In general, I'd like to have a code that will just tell me what the proper type string is for use in filters. I frequently use the following code (copied from a developer's post) to help me out, but I still can't find the method that will return the the information I am looking for here.

 

Public Class WhoAmI

        ' Must have UsePickSet specified
        <CommandMethod("WAI", _
          (CommandFlags.UsePickSet _
            Or CommandFlags.Redraw _
            Or CommandFlags.Modal))> _
        Public Shared Sub ObjectProperties()
            Dim doc As Document = _
              Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = doc.Editor
            Try
                Dim selectionRes As PromptSelectionResult
                selectionRes = ed.SelectImplied
                ' If there's no pickfirst set available...
                If (selectionRes.Status = PromptStatus.Error) Then
                    ' ... ask the user to select entities
                    Dim selectionOpts As PromptSelectionOptions
                    selectionOpts = New PromptSelectionOptions
                    selectionOpts.MessageForAdding = _
                      vbLf & "Select objects to list: "
                    selectionRes = ed.GetSelection(selectionOpts)
                Else
                    ' If there was a pickfirst set, clear it
                    'ed.SetImpliedSelection(Nothing)
                End If
                ' If the user has not cancelled...
                If (selectionRes.Status = PromptStatus.OK) Then
                    ' ... take the selected objects one by one
                    Dim tr As Transaction = _
                      doc.TransactionManager.StartTransaction
                    Try
                        Dim objIds() As ObjectId = _
                          selectionRes.Value.GetObjectIds
                        For Each objId As ObjectId In objIds
                            Dim obj As Object = _
                              tr.GetObject(objId, OpenMode.ForRead)
                            Dim ent As Entity = _
                              CType(obj, Entity)

                            Stop
                            'MsgBox(ent.ColorIndex)


                            ' This time access the properties directly
                            ed.WriteMessage(vbLf + "Type:        " + ent.GetType().ToString)
                            ed.WriteMessage(vbLf + "  ObjectID:    " + ent.ObjectId().ToString)
                            ed.WriteMessage(vbLf + "  Handle:    " + ent.Handle().ToString)
                            ed.WriteMessage(vbLf + "  Layer:      " + ent.Layer().ToString)
                            ed.WriteMessage(vbLf + "  Linetype:  " + ent.Linetype().ToString)
                            ed.WriteMessage(vbLf + "  Lineweight: " + ent.LineWeight().ToString)
                            ed.WriteMessage(vbLf + "  ColorIndex: " + ent.ColorIndex().ToString)
                            ed.WriteMessage(vbLf + "  Color:      " + ent.Color().ToString)
                            ' Let's do a bit more for circles...
                            If TypeOf (obj) Is Circle Then
                                ' Let's do a bit more for circles...
                                Dim circ As Circle = CType(obj, Circle)
                                ed.WriteMessage(vbLf + "  Center:  " + _
                                  circ.Center.ToString)
                                ed.WriteMessage(vbLf + "  Radius:  " + _
                                  circ.Radius.ToString)
                            End If
                            obj.Dispose()
                        Next
                        ' Although no changes were made, use Commit()
                        ' as this is much quicker than rolling back
                        tr.Commit()
                    Catch ex As Autodesk.AutoCAD.Runtime.Exception
                        ed.WriteMessage(ex.Message)
                        tr.Abort()
                    End Try
                End If
            Catch ex As Autodesk.AutoCAD.Runtime.Exception
                ed.WriteMessage(ex.Message)
            End Try
        End Sub

  Here is the code I use for implementing the Selection Set filter. The FilterString is the value I am looking for.

Private Function GetSelectionSet(ByVal FilterString As String) As ObjectId()

            '' Get the current document editor
            Dim acDocEd As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor

            '' Create a TypedValue array to define the filter criteria
            Dim acTypValAr(0) As TypedValue
            acTypValAr.SetValue(New TypedValue(DxfCode.Start, FilterString), 0)

            '' Assign the filter criteria to a SelectionFilter object
            Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)

            '' Request for objects to be selected in the drawing area
            Dim acSSPrompt As PromptSelectionResult
            acSSPrompt = acDocEd.GetSelection(acSelFtr)

            '' If the prompt status is OK, objects were selected
            If acSSPrompt.Status = PromptStatus.OK Then
                Dim acSSet As SelectionSet = acSSPrompt.Value
                'Dim idarray As ObjectId() = acSSet.GetObjectIds()

                Return acSSet.GetObjectIds()

            End If

        End Function

 Thanks a bunch.

AutoCAD Customization: .NET: how to create layouts for each drawing sheets in modelspace

$
0
0

Can anyone post me an example for creating layouts for the zoomed portion in the model space..Im able to zoom the drawing sheet but im not able to create layout for that sheet..See my attachment ..i created layouts manually(layout1,layout2,layout3)....But i dont know how to do this in .net API......Thanks....

AutoCAD Customization: .NET: VS 2010 No Source Available

$
0
0

I noticed that there was a few people myself included looking around the forum trying to find a solution to the Visual Studio No Source Available issues. Oddly enough I had one project that was working and one project that wasn't. After a bit of work trying to narrow it down I figured out something interesting.

 

In one project I was populating the form as modeless the other as modal. That being said I hd the issue whenever I used a modal form instead of a modeless. I am not sure if there is some other issue going on there but that is what I figured out thus far. I just thought I would make a post about it so that anyone else trying to find information on it might be able to get a solution here.

 

Now a quick note if your going to be using modeless forms your going to need to check out the issues with elockviolations and locking the document before accessing the database. There are other post on the form about this.

 

http://forums.autodesk.com/t5/NET/VB-Net-2013-eLockViolation/m-p/3901134/highlight/true#M34798


AutoCAD Customization: .NET: How can I use Mline Class to draw mline in dwg using C#?

$
0
0

hello,

I want to draw mline in the dwg automatically. Here is some codes, and what should I do next?

 

C# codes by VS2010,FOR AUTOCAD 2010.

 

 Line dashdot = new Line();   

 dashdot.Linetype = "DashDot";

 MlineStyleElement off1100 = new MlineStyleElement(3720/2,Autodesk.AutoCAD.Colors.Color.FromRgb (0,0,0),dashdot .LinetypeId );  

 MlineStyle mlineStyle = new MlineStyle();

  mlineStyle.Elements.Add(off1100,false );

Mline mline = new Mline(); 

mline.Style = mlineStyle.ObjectId;//HOW CAN I DEFINE THE MLINE? it should contain lines and I don't know

                                                      // how to add lines(may be points) into it.

 

The code may be wrong.

Please give me some help and advice.

Thanks in advance.

Allen

AutoCAD Customization: .NET: custom Dimension of Coordinate string

$
0
0

Hello,

I want to custom dimensions about text of the coordinate in DWG.

It should be like this:

 

I select a point then there displays a string of X,Y,Z coordinate of the point.

I select the second point to place a horizontal line(fixed lenth base the string font size)  and then the string.

the whole process is like radialDimension,but what I need is to describe the point x,y,z.

and the drawing should consist of start point(actually is the target point too) and end point and the line connects the two points and a horizontal line and a string.

 

Hopes you can get the right idea of what I want to express.

 

I think this should be completed using Dimension Class(should be CoordinateDimension based Dimension).

 

Please help me and give me some codes. Codes is better in C# of VS2010 for autoCAD2010.

 

Thanks in advance.

Allen

 

PS:

Actually there is a simple solution for this.

Using c# to draw two lines and a string.

But this is really bad experience when I want to move the string.

 

 

 

AutoCAD Customization: .NET: MlineStyle

$
0
0

Hello,

I want to use MlineStyle to custom mLine.

Here are my own codes and it does't work.

 

Line dashdot = new Line();

dashdot.Linetype = "Dash";  

MlineStyleElement off1100 = new MlineStyleElement(3720 / 2, Autodesk.AutoCAD.Colors.Color.FromRgb(0, 0, 0), dashdot.LinetypeId);

MlineStyle mlineStyle = new MlineStyle();   

mlineStyle.Elements.Add(off1100, false);          

Mline ml = new Mline();

ml.Style = mlineStyle.ObjectId;

 

How can I use MlineStyle?

 

Thanks in advance.

 

Allen

AutoCAD Customization: .NET: Problem in retreiving the active layout during plotting

$
0
0

Dear All:

 

This error happened to us, when we tried to get the active layout from the acad document. We are using AutoCAD 2009 & C#.NET 4.0 Framework.

The error is as below:

 

Unable to cast COM object of type 'Autodesk.AutoCAD.Interop.Common.AcadLayoutClass' to interface type 'Autodesk.AutoCAD.Interop.Common.IAcadLayout'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C6F55F5A-33AF-4B5F-9949-86C6AEEF1834}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 

The piece of snippet looks like the following

 

using Autodesk.AutoCAD.Interop.Common;

 

AcadApplication acadApp = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");

AcadDocument acadDoc = acadApp.ActiveDocument;

//The following line throws the error as stated above

AcadLayout aLayout = (AcadLayout)acadDoc.ActiveLayout;

 

But it can be accessed if we change the property " Embed Interop Types " of DLLs (a) Autodesk.AutoCAD.Interop

(b) Stdole

from True to False

 

But again it throws the same error when we try to retrieve any methods from the retrieved AcadLayout.

 

The whole application works fine with AutoCAD 2012 after re-referencing the DLLs.

 

Thank You!

Jagadeesh

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Path for the drawing containing block in script file

$
0
0

I am trying to make a script for inserting a standard title block  in some drawings. ( which needs to be often done for different projects). The title block is kept in the network path. How can i specify the path in the script file inorder to insert the block.

-Insert,> Block name > (I need to specify the drawing in the network to get the block in it) 

Can any one guide how to do it in script.

 

Viewing all 1680 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>