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

AutoCAD Customization: .NET: Monitoring If the Text Edit Ribbon Tab Is Open

$
0
0

Greetings,

 

How can I make a module that detects wether the text editing tab is open or not?

 

Best regards,

Ivan


AutoCAD Customization: .NET: Selecting then modifing results from import command, interop

$
0
0
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Interop
Imports System.Object
Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AutoCAD.Internal.Forms
Imports System
Imports System.IO
Imports System.Runtime.InteropServices


Namespace TestSelecting
    Public Class MyCommands

        <CommandMethod("Program")> Public Sub Program()
            '' Get the current document editor
            Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
            Dim acCurDb As Database = acDoc.Database
            Dim acDocEd As Editor = acDoc.Editor
            Dim AcadApp As Autodesk.AutoCAD.Interop.AcadApplication
            Dim acadDoc As Autodesk.AutoCAD.Interop.AcadDocument


            AcadApp = CType(GetObject(, "AutoCAD.Application.18.2"), Autodesk.AutoCAD.Interop.AcadApplication)
            '' Start a transaction
            Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()

                Dim ssetObj As AcadSelectionSet

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

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

                    '' Step through the objects in the selection set
                    For Each acSSObj As SelectedObject In acSSet

                        '' Check to make sure a valid SelectedObject object was returned
                        If Not IsDBNull(acSSObj) Then
                            '' Open the selected object for write
                            Dim acEnt As Entity = CType(acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite), Entity)
                            If Not IsDBNull(acEnt) Then
                                acadDoc = AcadApp.ActiveDocument
                               

                                Dim point(0 To 2) As Double
                                
                                point(0) = 2.0
                                point(1) = 2.0
                                point(2) = 0.0

                                Dim afterWMFObj As Object
                                afterWMFObj = acadDoc.Import("C:\Users\C\Documents\Drawing1.wmf", point, 2.0)
                                
                                
                                Dim newEntity As Entity = CType((acTrans.GetObject(CType(afterWMFObj, ObjectId), OpenMode.ForWrite)), Entity)

                                newEntity.ColorIndex = 3


                            End If
                        End If

                    Next

                    '' Save the new object to the database
                    acTrans.Commit()
                End If

                '' Dispose of the transaction
            End Using
        End Sub



    End Class
End Namespace

 

************** Exception Text **************
System.InvalidCastException: Specified cast is not valid.
   at TestSelectingFiltering.TestSelecting.MyCommands.FilterBlueCircleOnLayer0()
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()

 I'm trying to be able to add the results from the imported WMF into an entity, so that I'll be able to modify it later.

I keep getting this error. In this code I'm trying to change the imported WMF drawing to a green color.

 

Any help would be Awesome! -Thanks

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Save/close reactor

$
0
0

Hey folks,

 

as I discussed in an other post with Lee Mac, who was so kind to help me with some issues, I'm now dealing with some further problems and asking for help.

 

I'd like to run some Lisps whenever a user is saving or closing a file (for example move the bak.files to a certain folder). Lee already mentioned that this could be done via "Reactors". Now I searched the web for some answers, but didn't find any fitting solutions for my issue. :smileyfrustrated:

 

I'm happy for any help,

 

thanks guys,

Klingi

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: ±0.00 issue

$
0
0

Hey guys,

 

I'm running a Lisp, which was created by hmsilvia. It creates hightlabels based on the UCS in an elevation. I thought everything would work great, but then i mentioned that ±0.00 label won't work as it should. Everytime I update the height it removes the "±" in front of the 0.00. It works great with the "+" and "-" label, but won't run when there is no elevation.

 

any Ideas how to update the code?

here is the original code from hmsilvia:

 

(defun c:test ( / *error* ATT ENT HND ITM NUM OLD_ZIN PT S1 TXT Y)

  (defun *error* ( msg )
  (if Old_zin (setvar 'DIMZIN Old_zin))
  (if (not (member msg '("Function cancelled" "quit / exit abort")))
    (princ (strcat "\nError: " msg)))
  (princ)
  )

  (if (setq s1 (ssget "_:L" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," "__Hoehenkote")) '(66 . 1) (cons 410 (getvar 'CTAB)))))
    (progn
      (setq Old_zin (getvar 'DIMZIN))
      (setvar 'DIMZIN 0)
      (setq itm 0 num (sslength s1))
      (while (< itm num)
      (setq hnd	(ssname s1 itm))
	(if (eq	(vla-get-effectivename (vlax-ename->vla-object hnd)) "__Hoehenkote")
	  (progn
	    (setq ent (entget hnd)
		  att (entget (entnext hnd))
		  pt  (trans (cdr (assoc 10 ent)) 0 1)
		  y   (/ (cadr pt) 100.0))
	    (cond ((> y 0.0)
		   (setq txt (strcat "+" (rtos y 2 2)))
		  )
		  ((= y 0.0)
		   (setq txt (strcat "±" (rtos y 2 2)))
		  )
		  (T (setq txt (rtos y 2 2)))
	    );; cond
	    (entmod (subst (cons 1 txt) (assoc 1 att) att))
	  );; progn
	);; if
	(setq itm (1+ itm))
	);; while
      (setvar 'DIMZIN Old_zin)
      );; progn
    );; if
  (princ)
  );; test

 thanks for any help,

klingi

AutoCAD Customization: .NET: closing the default 'Drawing1'

$
0
0

Hi guys,

kindly I am using method to close the current file after plotting it, it works but it closes also the default file opend with Autocad which named 'Drawing1', another thing if there is any other drawing opend in Autocad it does not close it, I am wondering why?

 

 

        public void SaveAndClose(bool _boolSave)
        {
            AcadApplication app3 = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
            if (_boolSave == true)
            {
                app3.ActiveDocument.Save();
                app3.ActiveDocument.Close();
            }
            else
            {
                app3.ActiveDocument.Close();
            }

           
        }//end of saving and closing method

 thanks alot 

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Access block editor in table, right click etc

$
0
0

Has anyone made a customization to access block editor in table (table cell containing a block)?

Could be a command, a right click choice etc. By default, without such shortcut, you will firstly need to check the block name that is inserted by clicking the table cell, then run Bedit and scroll down to find the block.

 

thanks

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: load dws in acaddoc.lsp

$
0
0

Hey guys,

I know, that there are a few similar posts in the forum, but none worked for me, so maybe someone could help me with this issue...

 

I'd like to add a standardfile which is located in "I:\\AutoCAD Blöcke\\Template\\__Standard.dws" via Lisp to my drawings. It should be inside the acaddoc.lsp so everytime a file is opened it checks for this file.

 

The lisp should check if there is already a standardfile with this name. if so it shouldn't do anything, if there is an other one it should replace it or if there is none it should add the file...

 

Thanks for your help,

 

cheers Klingi

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: vla & vlax et. al.

$
0
0

There have been a bunch of times that I've needed to do something and the solution ended up involving these vla & vlax commands.  Can someone PLEASE point me to some documentation on using them (their syntaxt) and hopefully some sort of list of available functions?

 

I *think* these are classified as Visual Lisp functions.  But when I search for visual lisp documentation, all I find is info on using the VLISP IDE.

 

TIA!


AutoCAD Customization: Visual LISP, AutoLISP and General Customization: UCS Rotation from WCS?

$
0
0

How can I find the angle rotation between a UCS and WCS?

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Endpoint selection only for getpoint

$
0
0

I have a routine that I'm working on and it works great except that it currently uses getpoint which is too broad of an option for other users. How would I get an endpoint only selection for getpoint? Also, If an endpoint is not selected, prompt "Endpoint not selected" and not move on to the next part of the routine until endpoint is selected or exit command option entered? Here is an examploe of what I currently have:

 

    (setq YN (getkword "\nMove detail sheets? [Yes/No]: "))
    (if    (= "Yes" YN)
        (progn    (while    (and    (setq gp1 (getpoint "Pick LOWER LEFT corner of sheet to move <Done>: ")))
                (princ "\n ")
                (setq gp2 (getpoint "Pick LOWER RIGHT corner to move sheet to: " ))
                (princ "\n ")
                (if    (setq sel (ssget "_C" (mapcar '- gp1 '(0.0500 0.05 0.0)) (mapcar '+ gp1 '(5.1725 7.1 0.0))))
                    (command "._zoom" "E"
                         "_.move" sel "" "_non" gp1 "_non" gp2
                         "_.move" sel "" "_non" '(0.0 0.0) "_non" '(0.25 0.0))
                    (princ "\nNo objects found."))
            )
        (setq YN nil)
    )    )
    (princ)

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: how to determine which other files use YOUR drawing as an Xref?

$
0
0

ideally I'd love to have a way to determine which other drawing files use (reference as Xref) a particular file of mine.

Is there any way to do this, perhaps via a lisp?

 

any help appreciated!

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: LAYTRANS script

$
0
0

I'm trying to set up a script for batch processing some files, including a layer translation.  I used the advice from a JTB World Blog post to set this up.

Here is my line in the script:

 

(ACET-LAYTRANS "OBM topo Translate.dws" 5)

 

And here's what CAD says in response:

 

; error: no function definition: ACET-LAYTRANS

 

I've tried adding the path in the script, or adding it in my Support File Search Paths, but there is no difference.

Thanks.

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Pick using script file

$
0
0

In script I have tried using extrim command , I am not aware how to use pick (on the side where I require to trim) in script.

AutoCAD Customization: Visual Basic Customization: DWF Viewer embeded in VS 13

$
0
0

Originally posted this in the wrong forum. Was looking to get some help with this as soon as possible:

 

I've been having a problem embedding the Autodesk DWF Viewer Control in a Visual Studio form. I've successfully added the control to the toolbox, but everytime I attempt to add the DWF viewer to a form, it partially loads, and then visual studio crashes.

 

I've followed the appropriate steps in the Autodesk Review API 2013 to embed it, but still haven't managed to get this working.

 

Can anyone replicate this issue? If so, are there any available fixes to it?

 

Additionally, for the brief time that I was able to see the control layout (pre-crash), it looked outdated. It appeared similar to the old DWF viewer program before Autodesk Design Review. Is there a newer version of that control available?

 

Currently, I'm using VS 2013 Express for Web, and Autodesk Design Review 2013

 

Any assistance with this matter would be greatly appreciated.

AutoCAD Customization: Autodesk ObjectARX: COMException(0x8004001F3): Problem in loading application

$
0
0

Hi,

I'm recompiling for AutoCAD 2013/2014 a solution that works fine with AutoCAD 2012, composed of some ARX projects, one DBX project and one c#.NET project.


The c#.NET project implements an UI and contains a COM wrapper client that requires to "connect" to a ObjectARX project that is the COM wrapper server.


That ARX project contains a rgs file like this:

HKCR
{
   ArxName.AppComWr.2 = s 'AppComWrp Class'
   {
      CLSID = s '{7888DE6F-6301-481c-9C97-1F34F018BE22}'
   }
   ArxName.AppComWrp = s 'AppComWrp Class'
   {
      CLSID = s '{7888DE6F-6301-481c-9C97-1F34F018BE22}'
      CurVer = s 'ArxName.AppComWr.2'
   }
   NoRemove CLSID
   {
      ForceRemove {7888DE6F-6301-481c-9C97-1F34F018BE22} = s 'AppComWrp Class'
      {
         ProgID = s 'ArxName.AppComWr.2'
         VersionIndependentProgID = s 'ArxName.AppComWrp'
         ForceRemove 'Programmable'
         InprocServer32 = s '%MODULE%'
         {
            val ThreadingModel = s 'Apartment'
         }
         val AppID = s '%APPID%'
         'TypeLib' = s '{51526A5B-9E7F-41C6-A7EB-879F72721236}'
     }
   }
}

 

All compiles ok and can be loaded in AutoCAD. To do so I follow this steps:
1. compiled all the ARX projects and the DBX project.
2. I used "tlbimp ArxName.tlb /machine:64 /keyfile:NetName.snk /reference:Autodesk.AutoCAD.Interop.Common.Dll" to create the ArxNameLib.dll
3. I used "tlbimp DbxName.tlb /machine:64 /keyfile:NetName.snk /reference:Autodesk.AutoCAD.Interop.Common.Dll" to create the DbxNameLib.dll
4. used the two generated interop files in the NET project (like references), compiled it and generated the NetName.dll
5. registered the NetName.dll with: RegAsm.exe NetName.dll /codebase

 

The c#.NET project tries to initialize COM wrapper client with:

 

IAcadApplication iAcadApp =disp as IAcadApplication;
object cawrp =iAcadApp.GetInterfaceObject(_appComWrpProgId);

 

where _appComWrpProgId = "ArxName.AppComWr.2", a string that represents the ProgID of the COM wrapper server defined in rsg file described above.


The problem is that GetInterfaceObject generate the exception:

System.Runtme.InteropServices.COMException(0x8004001F3): Problem in loading application

It seems that the COM server isn't registered but I don't know what is the correct procedure to register it (and I didn't find clear information about it on the web).
I tried to use C:\Windows\SysWOW64\regsvr32.exe to register the ArxName.arx, but it returns error "Can't find specified module" (translated from italian).


All suggestions are welcomed.
Thank you.
Regards,
Tiziano


AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Programe not working properly

$
0
0

Programe not working properly;;

at the time selection of Insertion point, the display dcl box  not hide & also it should be show the selection point value in x,y,z or enter manually into the edit box.

Bolted.lsp

Bolt.dcl

Bolts Library.dwg

 

 

For Exercise use below data &colon;

Input M10;  40 ; DIN 931

Input M8;  10 ; DIN 933

 

AutoCAD Customization: .NET: get all verticies of a 2dPolyline

$
0
0

Is there a property or method to do this?

If not is there a round-about way?

AutoCAD Customization: .NET: Error Saving Drawing to older version of autocad map3d

$
0
0

Hi,

 

I am using autocad map3d 2013. I use the saveas method of autocad map3d 2013 api to save my document to previous version of autocad map3d. I got the error "The drawing contains custom objects that are not supported in previous versions. The objects cannot be save to previous version." It provide some steps to get around the error, one of which is to install autocad enablers. I check the site and found few installer. My question is what version should I download is compatible with autodesk map3d 2013?

 

Autocad Enablers Link: http://usa.autodesk.com/adsk/servlet/ps/dl/index?siteID=123112&id=2334440&linkID=9240858#section2

 

My snippet is here:

db.SaveAs(strSourceDWGPath,

True, DwgVersion.AC1015, doc.Database.SecurityParameters)

 

Note: attached is the error I receive.

 

Thanks and regards,

 

 

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: 2012 Startup Switch /p

$
0
0

W7 ACAD2012

After adding a Startup switch (/p "MyProfile") ) to my shortuct icon, ACAD has started freezing when launched. This was a very simple modification to the standard profile. The profile exists in the list. Thinking it was the change, I created another shortcut that calls the standard "<<Unnamed Profile>>" with the same result.

 

Also

When I saved the change to the shortcut I got a Admin notification about supply the admin password.

 

BTW

ACAD had been launching fine for several weeks until I made this change.

 

Any suggestions?

 

I also posted this in the General ACAD forum by mistake.

 

Thanks

Ray C.

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Changing colors from one layer to another safety

$
0
0

Hi All,

I have a lisp routine to change our specific colours to another so I can quickly update old DWG colors to our new standards. The Lisp routine works great however there is a duplicate colour 

So on the first run I want to change all colours 240->10 and 10->20. So on the firts run no problem. If I run it a second time then the original 240 colour will become 20, when I need it to stay 10. 

I've been trying to figure out how to put in a safety to stop this second change in case anyone runs it twice accidentally but I'm stumped...

 

Viewing all 1680 articles
Browse latest View live


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