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

AutoCAD Customization: .NET: how can i get the text information on the drawing

$
0
0

i want  to get all text font , text height and text widths on the drawing

 

Dim ListFont As New List(Of String)

For Each TextStyle As AcadTextStyle In ThisDrawing.TextStyles
ListFont.Add(TextStyle.fontFile)
Next

 

i used those code can get all text font on the drawing...but i only want to get text font which were used.

 

and i dont know how to get the text height and widths on the drawing.


AutoCAD Customization: .NET: Polyline direction (clockwise or counterclockwise)

$
0
0

I am trying to set up the bulge for  a polyline, in order to set up the bulge currecty I need to know if the polyline was created clockwise or counterclockwise.

 

Any advice would be appreciated.

 

-J

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Insert multiple images

$
0
0

How can Attach multiple images into autocad .? at a time ..!!

 

any lisp available ? :smileyhappy:

AutoCAD Customization: .NET: Dynamic preview of entities (mimic dimension style manager preview)

$
0
0

I have the dialog window with the settings for entities graphical appearance used in my plugin.

My goal is to create the same preview as AutoCAD dimension style manager dialog has, the dynamic thumbnail of the entities while user changes the settings in dialog.

Can someone give me idea or some approach how to do it.

 

Probably one option is to create temporary block (created based on data from settings dialog) and then use BlockTableRecord.PreviewIcon, but I am not sure if there is some other way.

 

Thank you,

Richard

AutoCAD Customization: .NET: Change WCS to Entity's UCS - problem.

$
0
0

Hello,

 

I would like to change current WCS to the object's UCS.

In AutoCAD I manually do this:

a) WCS -> OBject.

b) I'm selecting object;

c) PLAN.

 

I wrote this code:

 

     if (sourceObject is Entity)
                        {
                            Entity ent = (Entity)sourceObject as Entity;
                            Point3dCollection pts = new Point3dCollection();
                            ent.GetStretchPoints(pts);
                            Point3d pt = pts[0];

                            double viewsize = (double)Application.GetSystemVariable("VIEWSIZE");
                            Utilities.Command("UCS", "W");
                            Utilities.Command("UCS", "OB", pt);
                            Point3d center = (Point3d)Application.GetSystemVariable("VIEWCTR");
                            Utilities.Command("PLAN", "C");
                            Utilities.Command("ZOOM", "C", new Point3d(0, 0, 0), viewsize);
}

 Utilities.Command:

        public static void Command(params object[] args)
        {
            ResultBuffer resbuf = new ResultBuffer();
            foreach (object obj in args)
            {
                switch (obj.GetType().Name)
                {
                    case "String":
                        resbuf.Add(new TypedValue((int)LispDataType.Text, obj)); break;
                    case "Int16":
                        resbuf.Add(new TypedValue((int)LispDataType.Int16, obj)); break;
                    case "Int32":
                        resbuf.Add(new TypedValue((int)LispDataType.Int32, obj)); break;
                    case "Double":
                        resbuf.Add(new TypedValue((int)LispDataType.Double, obj)); break;
                    case "Point2d":
                        resbuf.Add(new TypedValue((int)LispDataType.Point2d, obj)); break;
                    case "Point3d":
                        resbuf.Add(new TypedValue((int)LispDataType.Point3d, obj)); break;
                    case "ObjectId":
                        resbuf.Add(new TypedValue((int)LispDataType.ObjectId, obj)); break;
                    case "ObjectId[]":
                        foreach (ObjectId id in (ObjectId[])obj)
                            resbuf.Add(new TypedValue((int)LispDataType.ObjectId, id));
                        break;
                    case "ObjectIdCollection":
                        foreach (ObjectId id in (ObjectIdCollection)obj)
                            resbuf.Add(new TypedValue((int)LispDataType.ObjectId, id));
                        break;
                    case "SelectionSetDelayMarshalled":
                    case "SelectionSetFullyMarshalled":
                        resbuf.Add(new TypedValue((int)LispDataType.SelectionSet, obj)); break;
                    default:
                        throw new InvalidOperationException("Unsupported type in Command() method");
                }
            }
            acedCmd(resbuf.UnmanagedObject);
        }

 But it doesn't work well - for the polyline in attachment.

 

I tried also this way:

 

 Matrix3d cur = ed.CurrentUserCoordinateSystem;
                            Vector3d x = new Vector3d(1, 0, 0);
                            Vector3d y = new Vector3d(0, 1, 0);
                            Point3d o = new Point3d(0, 0, 0);
                            Point3d center = (Point3d)Application.GetSystemVariable("VIEWCTR");
                            //double viewsize = (double)Application.GetSystemVariable("VIEWSIZE");
                            Matrix3d newUcsMat = Matrix3d.AlignCoordinateSystem(new Point3d(0, 0, 0), new Vector3d(1, 0, 0), new Vector3d(0, 1, 0), new Vector3d(0, 0, 1),
                               ent.Ecs.CoordinateSystem3d.Origin, ent.Ecs.CoordinateSystem3d.Xaxis, ent.Ecs.CoordinateSystem3d.Yaxis, ent.Ecs.CoordinateSystem3d.Zaxis);

                            ed.CurrentUserCoordinateSystem = newUcsMat;

 But still doesn't work.

 

Can anyone help me how to set current coordinate system to the object's UCS?

 

AutoCAD Customization: .NET: Construction Geometry and bulge

$
0
0

I would like to create a construction geometry that would behave as the Polyline Bulge. In other worlds I would like to create a Construction Arc that would have a Bulge. Upon examination, I was not able to locate any of the Construction Geometry that has a bulge.

 

The purpose of this is to determine the Bulge location (direction) of the polyline I am creating.

 

I would like to stay away from creating a database geometry, if possible -  please advice.

 

Thank you,

 

-J

AutoCAD Customization: .NET: Calling Civil3d code inside simple autocad.

$
0
0
Hi there.

I have a couple of questions:
1. Is it practical and possible to use civil3d api classes such as tinsurface etc in simple autocad by referencing aecdbmgd.dll if the objects are not appended to a database? That is, just for doing calculations etc?

2. Would it be legal?

It might sound like a silly question, kindly take it easy wih me :) thanks.

AutoCAD Customization: .NET: zoom an object and text

$
0
0

i want to zoom object by its properties, such as  i want to zoom the object was using 0.13mm lineweights or zoom the text which was using 3mm testheight


AutoCAD Customization: .NET: Avoiding duplicate Eventhandlers

$
0
0

In order to avoid duplicate eventhandlers, I did like the following...

 

Document doc = Application.DocumentManager.MdiActiveDocument;
try { doc.BeginDocumentClose -= new DocumentBeginCloseEventHandler(MyEventHandler); }
catch { // Do nothing }
doc.BeginDocumentClose += new DocumentBeginCloseEventHandler(MyEventHandler);

 

The above worked greatly with AutoCAD 2007.

But yesterday I migrated my code into AutoCAD 2010 (with Object ARX 2010).

 

Unfortunately, it seems like AutoCAD 2010 catches before my code catches it.... (Though I am not sure if this is even make sense)

 

The evidence...

 

error.PNG

 

If I ignore this message, everything works great as it was meant to be...

 

I am just wondering if I could disable(?) this. Or if there is any other effective work around....

Well, I guess I could just have a global boolean value that checks the status of event attachment.

But would this be the only way?

AutoCAD Customization: .NET: Ordinate dimension extents

$
0
0

I am drawing ordinate dimensions in blocks and then I am getting the geometric extents of these blocks, if the block contains the dimension, the extents are much larger than expected. What may be the cause?

 

See the attached drawing, the lines are  connecting geometric extents MinPoint and MaxPoint. For the blocks that don't have dimension in them, the extents are correct.

 

AutoCAD Customization: .NET: record history doesn't work on creating an extruded hehagon

$
0
0

 

Hi,

I am trying to create an extruded hexagon

EVERYTHING WORKS.... BUT:

after the creation of the hexagon the grips are not available even i added the proper code

(Polygon3d.record history = true)

Can somebody help me?

 

 

Thanks

 

See bellow my function.

 

    Public Function extrude_Hexagon(ByVal Centre_point As Point3d, ByVal radius_hexagon As Double, ByVal height_hexagon As Double) As Solid3d
        Try
            Dim ThisDrawing As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim Editor1 As Autodesk.AutoCAD.EditorInput.Editor = ThisDrawing.Editor
            Using Lock1 As DocumentLock = ThisDrawing.LockDocument


                Using Trans1 As Autodesk.AutoCAD.DatabaseServices.Transaction = ThisDrawing.TransactionManager.StartTransaction
                    Dim BTrecord As Autodesk.AutoCAD.DatabaseServices.BlockTableRecord = Trans1.GetObject(ThisDrawing.Database.CurrentSpaceId, OpenMode.ForWrite)



                    Dim Poly1 As New Autodesk.AutoCAD.DatabaseServices.Polyline

                    Dim Point00 As New Point2d(Centre_point.X + radius_hexagon, Centre_point.Y)
                    Dim Point01 As New Point2d(Centre_point.X + radius_hexagon * Cos(PI / 3), Centre_point.Y + radius_hexagon * Sin(PI / 3))
                    Dim Point02 As New Point2d(Centre_point.X - radius_hexagon * Cos(PI / 3), Centre_point.Y + radius_hexagon * Sin(PI / 3))
                    Dim Point03 As New Point2d(Centre_point.X - radius_hexagon, Centre_point.Y)
                    Dim Point04 As New Point2d(Centre_point.X - radius_hexagon * Cos(PI / 3), Centre_point.Y - radius_hexagon * Sin(PI / 3))
                    Dim Point05 As New Point2d(Centre_point.X + radius_hexagon * Cos(PI / 3), Centre_point.Y - radius_hexagon * Sin(PI / 3))

                    Poly1.AddVertexAt(0, Point00, 0, 0, 0)
                    Poly1.AddVertexAt(1, Point01, 0, 0, 0)
                    Poly1.AddVertexAt(2, Point02, 0, 0, 0)
                    Poly1.AddVertexAt(3, Point03, 0, 0, 0)
                    Poly1.AddVertexAt(4, Point04, 0, 0, 0)
                    Poly1.AddVertexAt(5, Point05, 0, 0, 0)
                    Poly1.Closed = True

                    Dim Segments_collection As New DBObjectCollection
                    Poly1.Explode(Segments_collection)


                    Dim Colectie_Regiune As New DBObjectCollection
                    Colectie_Regiune = Autodesk.AutoCAD.DatabaseServices.Region.CreateFromCurves(Segments_collection)

                    Dim Regiunea As New Region
                    Regiunea = Colectie_Regiune(0)
                    Dim Polygon3d As New Solid3d
                    Polygon3d.RecordHistory = True


                    Polygon3d.Extrude(Regiunea, height_hexagon, 0)



                    BTrecord.AppendEntity(Polygon3d)
                    Trans1.AddNewlyCreatedDBObject(Polygon3d, True)



                    Trans1.Commit()
                    Return Polygon3d

                End Using 



            End Using

        Catch ex As Exception

            MsgBox(ex.Message)
        End Try

    End Function

 

 

AutoCAD Customization: .NET: MLeader how to get the total scale of a mleader?

$
0
0

Hello alltogether,

 

how to set the total scale of a mleader in C#?

In German it's called: Gesamtskalierung

 

I had no Problem with this....

 

_mLeader.LandingGap = 6;

_mLeader.TextHeight = 60;

_mLeader.MLeaderStyle = _mleaderStyleId;

 

but the total scale is also very important for me....

 

I try to add a picture with a red frame so you

can see what I' missing.

 

Anika

 

 

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Lisp Routine Needed for Alerting you to overlapping Dimension LInes?

$
0
0

Hi Everyone, I hope I can discribe this well enough... sometimes someone dimensions a floor plan and starts one direction and then "goes back " the other way over the top of the dimension they just placed, which causes the dimension lines to overlap, which in turn shows incorrect distances when viewing on paper. Does anyone know of a lisp routine that can alert you to the fact that there are overlapping dimension lines (not the extension lines) in a drawing by changing them to color White or something? I have pasted a routine that we use which changes all dimenions with "modified text" to color white. That way I can see if someone just typed in the dimension distance they wanted instead of what was actually there. I don't know if this routine can be modified in anyway to acheive the results I'm asking for.

 

Any help would surely be appreciated.

 


(defun c:dc (/ dim_length)


(setq ssmod (ssget "X" (list (cons 0 "Dimension")(cons 1 "~"))))
(if ssmod
(progn
(setq dim_length (sslength ssmod))
(command "Change" ssmod "" "P" "C" "w" "")
(strcat "Found a total of ""< " (rtos dim_length 2 0) " >"" modified dimension(s), please verify. Use the DCB command to change the color back to BYLAYER")
);progn
(progn
(prompt "\nThere were no modified dimensions found...") (princ)
);end second program
); if

);end function

 

Thanks,

 

John W.

AutoCAD Customization: .NET: Need for help: hatch.appendloop function get message eInvalidInput

$
0
0

 i have a .dwg fille with some block reference.
 
I want to fill color for block reference, but when I debug to hatch.appendloop function, I get message eInvalidInput, and block don’t fill color.
 
This is my code:
 
[CommandMethod("FillColor")]
public void FillColor()
{
Document doc =
Application.DocumentManager.MdiActiveDocument;
Editor ed =
doc.Editor;
Database db =
HostApplicationServices.WorkingDatabase;
Transaction tr =
db.TransactionManager.StartTransaction();
 
// Start the transaction
try
{
// Build a filter list so that only
// block references are selected
TypedValue[] filList = new TypedValue[1] {
new TypedValue((int)DxfCode.Start, "INSERT")
};
SelectionFilter filter =
new SelectionFilter(filList);
PromptSelectionOptions opts =
new PromptSelectionOptions();
opts.MessageForAdding = "Select block references: ";
PromptSelectionResult res =
ed.GetSelection(opts, filter);
 
 
// Do nothing if selection is unsuccessful
if (res.Status != PromptStatus.OK)
return;
 
SelectionSet selSet = res.Value;
ObjectId[] idArray = selSet.GetObjectIds();
foreach (ObjectId blkId in idArray)
{
BlockTable bt =
(BlockTable)tr.GetObject(
db.BlockTableId,
OpenMode.ForRead
);
BlockTableRecord btr =
(BlockTableRecord)tr.GetObject(
bt[BlockTableRecord.PaperSpace],
OpenMode.ForWrite
);
 
 
 
Hatch hat = new Hatch();
hat.SetDatabaseDefaults();
 
hat.SetHatchPattern(HatchPatternType.PreDefined, "ANSI31");
hat.Color = Color.FromRgb(0, 0, 255);
 
// Add the hatch to the model space
// and the transaction
ObjectId hatId = btr.AppendEntity(hat);
tr.AddNewlyCreatedDBObject(hat, true);
 
// Add the hatch loop and complete the hatch
ObjectIdCollection ids = new ObjectIdCollection();
ids.Add(blkId);
hat.Associative = true;
hat.AppendLoop(HatchLoopTypes.Default, ids); // error here....
 
hat.EvaluateHatch(true);
 
}
tr.Commit();
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
ed.WriteMessage(("Exception: " + ex.Message));
}
finally
{
tr.Dispose();
}
}
 
Please help me, if you can!

AutoCAD Customization: .NET: how to use dxfcode.textfontfile , dxfcode.lineweight

$
0
0

Public Class Zoom
<CommandMethod("ZO")> _
Public Sub ZO()

 

Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument
Dim acDocEd As Editor = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.Editor
Dim acCurDb As Database = acDoc.Database

 


Dim acTypValAr(4) As TypedValue
acTypValAr.SetValue(New TypedValue(DxfCode.Operator, "<AND"), 0)
acTypValAr.SetValue(New TypedValue(DxfCode.Start, "TEXT,MTEXT"), 1)
acTypValAr.SetValue(New TypedValue(DxfCode.TextFontFile, "txt"), 2)

acTypValAr.SetValue(New TypedValue(DxfCode.lineweight, lineweight.lineweight030),3)
acTypValAr.SetValue(New TypedValue(DxfCode.Operator, "AND>"), 4)

 

Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)

Dim acSSPrompt As PromptSelectionResult
acSSPrompt = acDocEd.SelectAll(acSelFtr)

 

If acSSPrompt.Status <> PromptStatus.OK Then
Return
End If
Dim idCol As New ObjectIdCollection(acSSPrompt.Value.GetObjectIds())
ZoomObjects(idCol)

End Sub

 

 

acTypValAr.SetValue(New TypedValue(DxfCode.TextFontFile, "txt"), 2)

acTypValAr.SetValue(New TypedValue(DxfCode.lineweight, lineweight.lineweight030),3)

this two lines do not work.

what problem is it ???

 

and does it exist text hiegh and text width on dxfcode???


AutoCAD Customization: Visual Basic Customization: Reg. Z CoOrdinates Required While Inserting Block

$
0
0

Sub Example_InsertBlock()
    ' This example creates a block containing a circle.
    ' It then inserts the block.

    ' Create the block
    Dim blockObj As AcadBlock
    Dim insertionPnt(0 To 2) As Double
    insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
    Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "CircleBlock")
    
    ' Add a circle to the block
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 0: center(1) = 0: center(2) = 0
    radius = 1
    Set circleObj = blockObj.AddCircle(center, radius)
   
    ' Insert the block
    Dim blockRefObj As AcadBlockReference
    insertionPnt(0) = 2#: insertionPnt(1) = 2#: insertionPnt(2) = 0
    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)
    
    ZoomAll
    
End Sub

 

---------------------------------------------------------------------------------------------------------------------------------------------

 

This is the code for inserting block in the Model Space using COM API. In that you can ssee that while inserting block
we have to use array of double of size 3 insertionPnt(0 to 2)

 

So my question is while working with 2D, why 3rd CoOrdinate (Z-Coordinate) required ?
Let me correct If I am wrong then the need of double array of size 3 becuase we have 3 CoOrdinate (X,Y,Z) right ?

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: LISP to run batch files

$
0
0

Hi all,

 

I have to create some plines in a drawing from the inputs provided by the client. I prepared a lisp code for it. I have to use it to 1000 drawings. Every time I open the drawing and running the lisp command.

Is any lisp code to run in bulk open drawings with out entering command prompt.

 

Thanks

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Arguments in a call function are confused to a function call

$
0
0

When i call functionB on third row , arguments of this function call are recognized how a other function.

Error is "Error: incorrect function : 80(this the value of the first argument)"

(defun c:functionA ( k k1 f)
(setq k1 (/ (float k)  (float 100)))
(setq lst (functionB (k  f) ))
....
)

(defun fuctionB (kn first / a b c)
....
)

 

 

Can anyone help me? hi Lorenzo

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: image attach lisp

$
0
0

i am working on a lisp to attach an image with

 

(command "-image" "attach" path "0,0" "1" "0")  where 'path' is the prefix and image name set from a dialog box.

 

how can i get the program to error if the image does not exist- i.e., the name was incorrectly entered?  i have tried

 

(if  (= str "*Image not found*")
   (alert ":: ERROR :: Image not found")
)

 

and


(if (/= str "*Image not found*")
 (command "-image" "attach" path "0,0" "1" "0")
 (alert ":: ERROR :: Image not found")

)

 

the alert comes up regardless of whether or not the image exists.

AutoCAD Customization: .NET: Get current layer state

$
0
0

Can anyone point me in the right direction as to how to obtain the current layer state?

 

Thanks!

Viewing all 1680 articles
Browse latest View live


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