Quantcast
Viewing all 1680 articles
Browse latest View live

AutoCAD Customization: .NET: CloseAndDiscard throws an exception.

[Autodesk.AutoCAD.Runtime.CommandMethod("CD", CommandFlags.Session)]
        public static void CD()
        {
            DocumentCollection docs = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
            foreach(Document doc in docs)
            {
                if (doc.IsReadOnly)
                    doc.CloseAndDiscard();
                else
                {
                    if (docs.MdiActiveDocument != doc)
                    {
                        docs.MdiActiveDocument = doc;
                    }

                    doc.CloseAndSave(doc.Name);
                }
            }
        }

 The above code throws an exception from COM. Development environment VS2013, Autocad 2012, ObjectArx 2012. Anyone know why this code throws an exception???

 

Regards,

 

Mike


AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Help with existing LISP - Need to add a Multiply command

I have modified an existing LISP Routine to find the weight per foot of a 2D Profile for Aluminum Extrusion.

need to multiply the current result by 12.

I cannot figure out how to add this command or where to insert it.

Can anyone modify the attached LISP to acheive this result?

Any help would be greatly appreaciated.

Thank you

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Need A Sheet List Table Expert

I am trying to create a custom sheet set table to look exactly like my static sheet index that has just normal text. How do i add multiple columns after the 2nd column while keeping the row above it as one. I'm referring to the part where i have the revisions. I'm including some images of the screen shots that i did. Also how can i add a new row after a specific row? By the way, Anyone know of a good tutorial of tables?

My Table

Image may be NSFW.
Clik here to view.
My Table.jpg

 

My Index

Image may be NSFW.
Clik here to view.
My Index.jpg

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Association List to XML? Please help.

Hi all,

 

I have been tinkering away at this ever since it was suggested to utilize XML for data transport and storage and then W3C went and stated "If developers DO have sense, future applications will exchange their data in XML." So, it became a priority to me and perhaps you.

 

Many of us, including me, prefer to just stick with (A/V)LISP for as long as AutoCAD will accept it. I did many loong searches for hints of LISP to XML functions finding only the xml-api.lsp and it's great for what it does.

 

Because I still need a good simple way to generate the XML file to use the xml-api I have kicked around a way to dump an association list into xml format. Namely a way to construct valid XML from a structured association list. Atoms become tags and dotted pairs become attributes + values. Nesting is intrinsic of both although terminology is different they are essentially the same.

 

The code below is my current progress with help from Lee Mack & hmsilva (thank you both for those bits & pieces). I'm not an expert, obviously ;) but I know what I have this far is cool. My need for help here could be benefitial to anyone traveling this road or any developer whom has sense :)

 

Running the two test functions will reveal the situation. A top level list as with "testit1" works well (read notes), but as soon as I nest deeper, errors arise. I have an idea of what is needed but the code already has issues due to having been formed on top of a recursive function; and, I'm struggling to solve.

 

Can you help?

 

(DEFUN ASSOC->XML (l)
  (VL-LOAD-COM)
  
  (DEFUN XMLify (data / x y z) ;| hmsilva - http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Recursively-check-for-characters-and-substitute/m-p/4845525#M320052 |;
    (SETQ x '("<" ">" "& " "'" "\"")
	  y '("&lt;" "&gt;" "&amp; " "&apos;" "&quot;")
	  z (LENGTH x)
    )
    (WHILE (NOT (MINUSP (SETQ z (1- z))))
      (WHILE (VL-STRING-SEARCH (NTH z x) data)
        (SETQ data (VL-STRING-SUBST (NTH z y) (NTH z x) data))
      )
    )
    data
  )

  (DEFUN rtn-str (val) (IF (EVAL val) (IF (= (TYPE val) 'int) (ITOA val) val)))
  
  (FOREACH i l
    (COND
      ; <- Somehow collect parents nodes for closing later 
      ((ATOM i)
       (IF (EQ i (STRCASE i))
	 (PROGN
	   (IF (AND (/= ax|p i) (NOT (NULL ax|p)))
	     (PROGN (WRITE-LINE (STRCAT " /></" ax|p "><" i) output)
		    (SETQ ax|p i ax|t nil)
	     )
	     (PROGN (SETQ ax|p i) (WRITE-LINE (STRCAT "<" i) output))
	   )
	 )
	 (IF (NULL ax|t)
	   (PROGN (WRITE-LINE (STRCAT "><" (STRCASE ax|p T) " ITEM=\"" i "\"") output) (SETQ ax|t T))
	   (PROGN (WRITE-LINE (STRCAT " /><" (STRCASE ax|p T) " ITEM=\"" i "\"") output) (SETQ ax|t nil))
	 )
       )
      )
      ((= (CDR i) nil) (ASSOC->XML (CDR i)))
      ((NOT (OR (ATOM i) (LISTP (CDR i))))
       (WRITE-LINE
	 (STRCAT (IF (VL-SYMBOLP (CAR i)) (VL-SYMBOL-NAME (CAR i)) (CAR i))
		 "=\"" (XMLify (rtn-str (CDR i))) "\""
	 ) output
       )
       (SETQ ax|t T)
      )
      ((LISTP i) (ASSOC->XML i))
    )
  )
  ; <- Somehow close parent nodes before exiting 
  (PRINC)
)

;;| Tests 1 & 2 
(DEFUN c:testit1 ()
  (SETQ	ax|p nil ax|pp nil ax|t nil)
  (ASSOC->XML
    (CDR
      '(SOFTSCAPE ("PALM" ("Pygmy Palm" (BOTANICAL . "Phoenix robelinii") (SIZE . " 15 GAL") (COLOR) (QTY . 2)))
		  ("SHRUB" ("Arizona Yellow Bells" (BOTANICAL . "Tecoma stans var. agustata") (SIZE . " 5 GAL") (COLOR) (QTY . 2))
			   ("Brave River Sage" (BOTANICAL . "Leucophyllum langmaniae") (SIZE . " 5 GAL") (COLOR) (QTY . 6))
			   ("Chuparosa" (BOTANICAL . "Justicia californica") (SIZE . " 5 GAL") (COLOR) (QTY . 4))
			   ("Pink Fairy Duster" (BOTANICAL . "Calliandra eriophylla") (SIZE . " 5 GAL") (COLOR . "PINK") (QTY . 5))
		  )
		  ("GROUNDCOVER" ("New Gold Lantana" (BOTANICAL . "Lantana hybrid 'New Gold'") (SIZE . " 5 GAL") (COLOR) (QTY . 5)))
		  ("ACCENT" ("Ocotillo" (BOTANICAL . "Fouquieria splendens") (SIZE . " bare root") (COLOR) (QTY . 1))
			    ("Toothless Desert Spoon" (BOTANICAL . "Dasylirion quadrangulatum") (SIZE . " 5 GAL") (COLOR) (QTY . 2))
		  )
		  ("CACTUS" ("Argentine Giant" (BOTANICAL . "Trichocereus candicans") (SIZE . " 5 GAL") (COLOR) (QTY . 1))
			    ("Mexican Fencepost" (BOTANICAL . "Pachycereus marginatus") (SIZE . " 5 GAL") (COLOR) (QTY . 2))
			    ("Purple Prickley Pear" (BOTANICAL . "Opuntia violacea 'Santa Rita'") (SIZE . " 5 GAL") (COLOR) (QTY . 2))
		  )
		  ("LIGHTS" ("Path" (BOTANICAL) (SIZE) (COLOR . "RUST") (QTY . 5))
			    ("Spot" (BOTANICAL) (SIZE) (COLOR . "RUST") (QTY . 5))
			    ("Transformer" (BOTANICAL) (SIZE) (COLOR) (MODEL . "300") (QTY . 1))
		  )
       )
    )
  )
  (PRINC (STRCAT " /></" ax|p ">")) ; Close parent tag 
  (if ax|pp (princ (strcat "</" ax|pp ">"))) ; Close top-level parent tag 
  (SETQ	ax|p nil ax|pp nil ax|t nil) ; empty globs 
  (PRINC)
)

(DEFUN c:testit2 ()
  (SETQ	ax|p nil ax|pp nil ax|t nil)
  (ASSOC->XML 
    '("DrawingData" (DATEDRAWN . "1/6/14") (DRAFTNAME . "Me")
	(REVISIONS ("REVISION1" (WHO . "You") (WHEN . "2/16/2014") (WHAT . "Material colors, CO# 52498"))
		   ("REVISION2" (WHO . "Another") (WHEN . "2/24/2014") (WHAT . "SQFT Adjusted"))
		   ("REVISION3" (WHO . "You") (WHEN . "2/25/2014") (WHAT . "Something else"))
		   ("REVISION4" (WHO . "Other") (WHEN . "2/26/2014") (WHAT . "Add Coping, CO# 52633"))
		   ("REVISION5" (WHO . "Another") (WHEN . "2/28/2014") (WHAT . "Add Sand color"))
		   ("REVISION6" (WHO . "Me") (WHEN . "3/2/2014") (WHAT . "Revised Per Layout"))
		   ("REVISION7" (WHO . "Other") (WHEN . "3/4/2014") (WHAT . "Change Per Super, CO# 52891"))
	)
        (SOFTSCAPE ("PALM" ("Pygmy Palm" (BOTANICAL . "Phoenix robelinii") (SIZE . " 15 GAL") (COLOR) (QTY . 2)))
		   ("SHRUB" ("Arizona Yellow Bells" (BOTANICAL . "Tecoma stans var. agustata") (SIZE . " 5 GAL") (COLOR) (QTY . 2))
			    ("Brave River Sage" (BOTANICAL . "Leucophyllum langmaniae") (SIZE . " 5 GAL") (COLOR) (QTY . 6))
			    ("Chuparosa" (BOTANICAL . "Justicia californica") (SIZE . " 5 GAL") (COLOR) (QTY . 4))
			    ("Pink Fairy Duster" (BOTANICAL . "Calliandra eriophylla") (SIZE . " 5 GAL") (COLOR . "PINK") (QTY . 5))
		   )
		   ("GROUNDCOVER" ("New Gold Lantana" (BOTANICAL . "Lantana hybrid 'New Gold'") (SIZE . " 5 GAL") (COLOR) (QTY . 5)))
		   ("ACCENT" ("Ocotillo" (BOTANICAL . "Fouquieria splendens") (SIZE . " bare root") (COLOR) (QTY . 1))
			     ("Toothless Desert Spoon" (BOTANICAL . "Dasylirion quadrangulatum") (SIZE . " 5 GAL") (COLOR) (QTY . 2))
		   )
		   ("CACTUS" ("Argentine Giant" (BOTANICAL . "Trichocereus candicans") (SIZE . " 5 GAL") (COLOR) (QTY . 1))
			     ("Mexican Fencepost" (BOTANICAL . "Pachycereus marginatus") (SIZE . " 5 GAL") (COLOR) (QTY . 2))
			     ("Purple Prickley Pear" (BOTANICAL . "Opuntia violacea 'Santa Rita'") (SIZE . " 5 GAL") (COLOR) (QTY . 2))
		   )
		   ("LIGHTS" ("Path" (BOTANICAL) (SIZE) (COLOR . "RUST") (QTY . 5))
			     ("Spot" (BOTANICAL) (SIZE) (COLOR . "RUST") (QTY . 5))
			     ("Transformer" (BOTANICAL) (SIZE) (COLOR) (MODEL . "300") (QTY . 1))
		   )
        )
     )
  )
  (PRINC (STRCAT " /></" ax|p ">")) ; Close parent tag 
  (if ax|pp (princ (strcat "</" ax|pp ">"))) ; Close root tag 
  (SETQ	ax|p nil ax|pp nil ax|t nil) ; empty globs 
  (PRINC)
)

 

Any help and/or advice is greatly appreciated. (BTW- this version does not write to a file, that is the easy part. If you choose to test it use textscr to view the results)

 

Thank you.

AutoCAD Customization: .NET: can anyone give the c# code whitch can create a 'wipeout'?

can anyone give me some c# code whitch can create a 'wipeout'?

thanks

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Newb want to make as-built program in LISP

Hello

 

I don't know about LISP yet, but I am reading: http://docs.autodesk.com/ACDMAC/2013/ENU/PDFs/acdmac_2013_autolisp_developers_guide.pdf.

I want to make a little program where I can show with an arrow and an annotation, the distance (in mm.) and the perpendicular direction for a point to meet the design (defined by 2 points). To start with, the program will be in 2D (X,Y).

Do you know some reading or exemples, who could help me to do so?

As I know from programming in another language I have to:

1 launch/start the program

2 click/choose the 2 points I need to relate my measurement to

3 click/choose the point(s) the measured points

 

Best Regards

Jean-Christophe

 

 

 

 

AutoCAD Customization: .NET: ReadDwgFile fatal error Map3d 2014

Hi,

 

I'm trying to open a file in vb.net to read some of the xrefs within it, and I have narrowed down the fatal error that is being generated by the following code.   I have tried both of the differences I have listed below and both produce a fatal error when the ReadDwgFile is envoked.  Can someone tell me why that may be happening?

 

 Dim myDB As New Autodesk.AutoCAD.DatabaseServices.Database
        myDB.ReadDwgFile(dwgfile, FileOpenMode.OpenForReadAndWriteNoShare, False, "")

 

Or this:

 Dim myDB As New Autodesk.AutoCAD.DatabaseServices.Database
        myDB.ReadDwgFile(dwgfile, IO.FileShare.ReadWrite, True, "")

 

Thanks

AutoCAD Customization: .NET: NOOB QUESTION

I am attempting to customize reports in Civil 3D 2013.  I load the vbproj (in Visual Studio 2010) and without making any changes, build the project.  When I attempt to run the reports, Civil 3D reports errors running the reports.  One thing that I notice when I load the project, I am prompted that the References are missing the path.

 

I can modify the reports, but for the world of me, I can't figure out why building the project causes errors.


AutoCAD Customization: Visual LISP, AutoLISP and General Customization: modift lisp-for copy from xref

I have the following code yo copy from xref.

all thing is fine except color,the color of objects are not as bylayer .

Thanks

Hamid

 

 


(defun c:xcp(/ blo cod ent nom sel)
 (and (setq sel (nentselp))
 (= (type (setq blo (last (last sel)))) 'ENAME)
 (/= (logand (cdr (assoc 70 (tblsearch "block" (setq nom (cdr (assoc 2 (entget blo))))))) 124) 0)
 (setq ent (entget (car sel)))
 (progn
 (foreach cod '(-1 5 330)
 (setq ent (vl-remove (assoc cod ent) ent))
 )
 (foreach cod '(6 8)
 (and (assoc cod ent)
 (eq (substr (cdr (assoc cod ent)) 1 (strlen nom)) nom)
 (setq ent (subst (cons cod (substr (cdr (assoc cod ent)) (+ (strlen nom) 2))) (assoc cod ent) ent))
 )
 )
 (entmake ent)
 (setq obj (vlax-ename->vla-object (entlast)))
 (vla-transformby obj (vlax-tmatrix (caddr sel)))
 )
 )
 (princ)
 )

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: AEC Window Block - how to extract ht width and head height

When I go to extract DXF code info out of an AEC Window block (primarily looking for window width, height, and head ht codes) I get the following information which is very basic. is there a way to drill down further to get more data on the information I'm looking for?

 

(setq ed (entget ( car (entsel))))

Select object: ((-1 . <Entity name: 7fffee1c020>) (0 . "AEC_WINDOW") (330 . <Entity name: 7ffff1e09f0>) (5 . "64CA") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "A-Glaz-F1"))

 

Thanks,

 

John W

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: thiessen polygon Lisp

Hi

for design of water and wastewater networks, one of the most imporant issues is calculation of contributed area.

and one of the best methods is "thiessen polygon method"

Attached explains about this method.

I really would like to have a lisp file that by haveing some points (pipes intersections ) can indicate contributed area.

Thanks a lot in advance and looking forward to hearing from you.

Hamid

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: putting inserts in paperspace

Good afternoon to all,


With the following code I try to achieve the placement of partnumber balloons and a BOM line in layouts of my drawing.Through the use of a template file I have 3 layouts available each with an insert present of a block called "bomblock" . The partnumber balloons and the BOM are always in Paperspace!

This codes works only if I go to the layout which is first in the row of tabs allowing to select a layout and start my partnumbering here. Any other way it seems to lose track of the place in the layout->block where I happen to work, placing a new insert in the wrong layout and subsequently updating this inserts' atributes in yet another instance of an insert, even on another layout.

The code is triggerd (with a button on a toolbar) once per partnumber.


What am I missing?


;| ===============================================================================
Function (pnum)
Created by Willem van Rij, Brix Engineering
Date feb 2014
Status test
-------------------------------------------------------------------------------
Action create a BOM above cartouch and asks for placement of Partnumber balloon
Return

Remark
---------------------------------------------------------------------------------
|;

(defun pnum (/ atts dcl_id i res l_o_blok inspoint bl attribvals dcl)
(vl-load-com)
(setq *acad-object* nil) ; Initialize global variable
(defun acad-object ()
(cond (*acad-object*) ; Return the cached object
(t
(setq *acad-object* (vlax-get-acad-object))
)
)

)

(setq *active-document* nil) ; Initialize global variable
(defun active-document ()
(cond (*active-document*) ; Return the cached object
(t
(setq *active-document* (vla-get-activedocument (acad-object)))
)
)

)

(setq *model-space* nil) ; Initialize global variable
(defun model-space ()
(cond (*model-space*) ; Return the cached object
(t
(setq *model-space* (vla-get-modelspace (active-document)))
)
)

)
(setq *paper-space* nil) ; Initialize global variable
(defun paper-space ()
(cond (*paper-space*) ; Return the cached object
(t
(setq *paper-space* (vla-get-paperspace (active-document)))
)
)

)
(VLA-put-ActiveSpace (active-document) acPaperSpace)

(setq dcl "D:\\AC2007\\lsp\\bom.dcl"
l_o_blok
(vla-get-block (vla-get-activelayout (active-document)))

i 0

)
(WriteDCL dcl (vla-get-name (vla-get-layout l_o_blok)))
(setq dcl_id (LOAD_DIALOG dcl))


(vlax-for res l_o_blok
(if (and
(= (vla-get-objectname res) "AcDbBlockReference")
(= (vla-get-name res) "bomblock")
(= (vla-get-hasattributes res) :vlax-true)
)
(progn
(setq atts (vlax-safearray->list
(VLAX-VARIANT-VALUE (vla-GetAttributes res))
)
)
(mapcar '(lambda (x)
(if (= (STRCASE (VLA-GET-TAGSTRING x)) "POS")
(if
(= (strcase (VLA-GET-TEXTSTRING x))
"-"
)
(progn (setq i 0
inspoint (vla-get-insertionpoint res)
)
)
(if (< i (atoi (VLA-GET-TEXTSTRING x)))
(setq i (atoi (VLA-GET-TEXTSTRING x))
inspoint (vecadd (vla-get-insertionpoint res)
(vlax-3d-point '(0 8 0))
)

)
)
)
)
)
atts
)

)
)
)
(NEW_DIALOG "pos_num" dcl_id)
(SET_TILE "pos" (ITOA (1+ i)))
(ACTION_TILE
"accept"
"(progn (setq attribvals (get_dcl)) (done_dialog))"
) ;_ end of action_tile
(START_DIALOG)
(UNLOAD_DIALOG dcl_id)
(setq bl
(VLA-INSERTBLOCK
l_o_blok inspoint "BOMBLOCK" 1 1 1 0)
atts (vlax-safearray->list
(VLAX-VARIANT-VALUE (vla-GetAttributes bl))
)
)
(MAPCAR '(LAMBDA (x)
(VLA-PUT-TEXTSTRING
x
(CDR (ASSOC (VLA-GET-TAGSTRING x) attribvals))
) ;_ end of vla-put-textstring
) ;_ end of lambda
atts

)
(balloon (ITOA (1+ i)))
)


;|---------------------------------------------------------------------|;

(DEFUN get_dcl (/ res)
(SETQ res (LIST (CONS "POS" (ATOI (GET_TILE "pos")))
(CONS "N_OFF" (ATOI (GET_TILE "noff")))
(CONS "DESC" (GET_TILE "def"))
(CONS "REF" (GET_TILE "bw"))
) ;_ end of list
) ;_ end of setq
(REVERSE res)
) ;_ end of DEFUN

;|---------------------------------------------------------------------|;

(DEFUN BALLOON (BALLOON_DEFTXT / A A1 H R i l_ent ssl ss)
(PRINC "Place part number balloon: ")
(COMMAND "_.LAYER" "_MAKE" "POSNUMS" "")
(SETQ pdefs '("10" "45%" "phead" "1")
ss (SSADD)
) ;_ end of setq
(SETQ
H (* (ATOF (CAR pdefs))
(/ (ATOF (SUBSTR (CADR pdefs) 1 (- (STRLEN (CADR pdefs)) 1)))
100
) ;_ end of /
) ;_ end of *
) ;_ end of setq
(SETQ R (/ (ATOF (CAR pdefs)) 2))
(SETQ ssl (SSLENGTH ss))
(SETQ A (GETPOINT "\nFrom Point: "))
(COND ((= (CADDR pdefs) "phead")
(COMMAND "color"
"white"
)
(COMMAND "_DONUT" "0" "1.5" A "")

;; (command "") ;_ end of command
(SSADD (ENTLAST) ss)
)
) ;_ end of cond
(WHILE A
(SETQ A1 (GETPOINT A "\nTo point: "))
(IF (NULL (NULL A1))
(PROGN
(IF (AND (= (- ssl (SSLENGTH ss)) 0) (= (CADDR pdefs) "ahead"))
(PROGN (COMMAND "color"
"white"
"_.INSERT"
(STRCAT BWAPPLIC_PATH "iahead")
A
(ATOF (CADDDR pdefs))
(ATOF (CADDDR pdefs))
(rtod (ANGLE A A1))
) ;_ end of command
(SSADD (ENTLAST) ss)
) ;_ end of progn
) ;_ end of if
(COMMAND "color" "white" "_.line" A A1 "")
(SSADD (ENTLAST) ss)
(SETQ A A1
A1 nil
) ;_ end of setq
) ;_ end of progn
(PROGN (COMMAND "_.color" "magenta")
(SETQ l_ent (SSNAME ss (- (SSLENGTH ss) 1))
A (CDR (ASSOC 10 (ENTGET l_ent)))
A1 (CDR (ASSOC 11 (ENTGET l_ent)))
ss (SSDEL l_ent ss)
) ;_ end of setq
(ENTDEL l_ent)
(COMMAND "_.text" "J" "M" A1 H "0" BALLOON_DEFTXT)
(SSADD (ENTLAST) ss)
(COMMAND "_.color" "yellow")
(COMMAND "_.circle" A1 R)
(SSADD (ENTLAST) ss)
(COMMAND "_.color" "white")
(COMMAND "_.line"
A
(POLAR A (ANGLE A A1) (- (DISTANCE A A1) R))
""
) ;_ end of command
(SSADD (ENTLAST) ss)
(SETQ A nil
A1 nil
) ;_ end of setq
) ;_ end of progn
) ;_ end of if
) ;_ end of while
(SETQ i 0)
ss
) ;_ end of defun

(defun WriteDCL (fname titel / fh)
;;; (findfile fname)
(and
(setq fh (open fname "w"))
(foreach str
(list
"//------------=={ BOM.dcl Dialog Definition }==-----------//"
"// //"
"// Author: Lee Mac, Copyright © 2011 - www.lee-mac.com //"
"//----------------------------------------------------------//"
""
(strcat "pos_num :dialog{label =\""
(vla-get-name (vla-get-layout l_o_blok))
"\";"
)
":column{:boxed_row { label = \"General:\";"
": edit_box {key = \"pos\"; label = \"&Partnumber\"; width = 20; fixed_width = true;}"
": edit_box { key = \"noff\"; label = \"&Number off\"; width = 20; fixed_width = true;}}"
": boxed_row {label = \"Description:\";"
": edit_box { key = \"def\"; label = \"&Definition \";width = 50;fixed_width = true;edit_limit = 60;}}"
": boxed_row {label = \"References:\"; : edit_box { key =\"bw\"; label = \"&Referentie\"; width = 50; action = \"(setq activetile $key)\"; fixed_width = true; edit_limit = 60; }}}"
" ok_cancel;}"

"//----------------------------------------------------------//"
"// End of File //"
"//----------------------------------------------------------//"

)
(write-line str fh)
)
(setq fh (close fh))
)
)

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Automation Error: Problem in loading Application

Hello all.

I have a LISP routine that I wrote years ago that I am having an issue with in ACAD 2014.

The routine loads but when I try to run it I get an error stating "Automation Error: Problem in loading Application"

I have narrowed it down to this line of code where it is blowing up:

(setq colorObj (vla-getinterfaceobject (vlax-get-acad-object) "AutoCAD.AcCmColor.18"))

My belief is that is has something to do with the vla-getinterfaceobject function but I cant find a way around it.

Does anyone have any ideas for me?

Thanks in advance.

AutoCAD Customization: .NET: i want to create a viewport in a layout, but the code generate a importdll error

i want to create a viewport in a layout, and i get some code from kean's blog, but the code generate a importdll error, please help me!

the system is Win7x64bit+AutoCAD2013

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using AcGi = Autodesk.AutoCAD.GraphicsInterface;

namespace sample
{
public class paperViewport
{

[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedSetCurrentVPort@@YA?AW4ErrorStatus@Acad@@PBVAcDbViewport@@@Z")]
extern static private int acedSetCurrentVPort(IntPtr AcDbVport);

[CommandMethod("CreateFloatingViewport")]
public static void CreateFloatingViewport()
{
// Get the current document and database, and start a transaction
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;

using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the Block table for read
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;

// Open the Block table record Paper space for write
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();

// Create a Viewport
Viewport acVport = new Viewport();
acVport.CenterPoint = new Point3d(3.25, 3, 0);
acVport.Width = 6;
acVport.Height = 5;

// Add the new object to the block table record and the transaction
acBlkTblRec.AppendEntity(acVport);
acTrans.AddNewlyCreatedDBObject(acVport, true);

// Change the view direction
acVport.ViewDirection = new Vector3d(1, 1, 1);

// Enable the viewport
acVport.On = true;

// Activate model space in the viewport
acDoc.Editor.SwitchToModelSpace();

// Set the new viewport current via an imported ObjectARX function

//error message:Unable to find an entry point named '?' in DLL 'acad.exe'.
acedSetCurrentVPort(acVport.UnmanagedObject);

// Save the new objects to the database
acTrans.Commit();
}
}

}

 

}

AutoCAD Customization: Visual Basic Customization: 3dalign

Please help me how to code 3d align in vba.

 


AutoCAD Customization: .NET: make one dll run in all autocad versions?

i want to make a dll that can run in autocad version from 2004 to 2014,how many projects will be compiled?

Or is there any methods to make only one dll and met all the 2007 to 2014 version?

thanks

swaywood

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Leader Code

Hi,

I need Visual Lisp code for the leader i have attached.

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Can Sheet Sets be modified with Lisp?

Can you modify the names of the sheets with lisp? We have a project startup routine that copies files from a central network location into our project directory & renames the files to for instance project x plan.dwg. When i copy over my sheet set template it refers to the name that is in the the central netowrk location which is called 0000 storename plan.dwg. I want the new sheet set to be linked with a drawing called projectx plan.dwg. Im trying to avoid having to edit the sheet manager for every project that we do.

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Copy lisp routine issue

Hi there!
I'm new in the community, recently I was robbed and I lost all my lisp documentation.
So I've been doing some research to get some lisp routines and I find this:

 

(defun C:CEE (/ trap1 temperr oldsnap copy_objects) ; COPY from Endpoint to Endpoint

(defun trap1 (errmsg)
(command "_.undo" "_end") ; undo end
(setvar "osmode" oldsnap) ; restore variables
(setvar "cmdecho" 1) ; enable cmdecho
(setq *error* temperr) ; restore old error handler
(prompt "\nResetting System Variables ") ; inform user
(princ)
); defun

(setq temperr *error*) ; save error handler
(setq *error* trap1) ; assign error handler to trap1
(setq oldsnap (getvar "osmode"))

(setvar "cmdecho" 0) ; disable command echo
(setvar "osmode" 1) ; set ENDPOINT osnap
(command "_.undo" "_begin") ;undo begin

(setvar "cmdecho" 1) ; enable cmdecho

(if (setq copy_objects (ssget))
(progn
(command "_.copy" "si" copy_objects "_m")
(while (/= (getvar "cmdactive") 0)
(command pause)

(setvar "osmode" 1) ; set ENDPOINT osnap

); while
); progn
); if

(setvar "cmdecho" 0) ; disable cmdecho
(trap1 "done")
)

 

The routine works ok, but, my problem is that, when I pick any point on the screen, the object selected it's been posted on that point.
The objective of the routine (which I did modify from the original one), is to avoid mistakes caused for other snaps or simple sloppy fingers.
So, my question is if any body can help me to modify it in a way that only can copy from end point to end point.

I already tried with something like this: "(command "COPY" PAUSE "" "end" PAUSE "end" PAUSE)", but it just doesn't feel right.

Thank you in advance for your help

AutoCAD Customization: .NET: error 91

Hi! I'm not sure if I should publish this post here, but I'm trying to do something between Excel and Autocad with VSTO and Autocad type library and all this with vb.net

 

This is part of my code:

 

Dim PTRange, XRange, YRange, ZRange, CDRange, HTRange As Excel.Range

Dim North, Easte, Elevation As Double

Dim BlockName As String = "UTM"

Dim PtXYZ As Double()

Dim ValScale, ARotation As Double

ValScale = Convert.ToDouble(1)

ARotation = Convert.ToDouble(0)

 

Try

CAD_App = GetObject(, "AutoCAD.Application")

CAD_Doc = CAD_App.ActiveDocument

 

Try

For I AsInt16 = Fila To FilaEnd

'PTRange = XlSheet_GetValues.Cells(I, 1)

'Punto = PTRange.Value

YRange = XlSheet_GetValues.Cells(I, 2)

North = Convert.ToDouble(YRange.Value)

XRange = XlSheet_GetValues.Cells(I, 3)

Easte = Convert.ToDouble(XRange.Value)

ZRange = XlSheet_GetValues.Cells(I, 4)

Elevation = Convert.ToDouble(ZRange.Value)

'Cota = ZRange.Value

'CDRange = XlSheet_GetValues.Cells(I, 5)

'Descripcion = CDRange.Value

 

PtXYZ = NewDouble() {Este, Norte, Elevation}

'PtXYZ(0) = Este : PtXYZ(1) = Norte : PtXYZ(2) = Elevation

 

Dim Acad_BlockInsert As AcadBlockReference

 

'CAD_Model.InsertBlock(PtXYZ, BlockName, ValScale, ValScale, ValScale, ARotation)

Acad_BlockInsert = CAD_Model.InsertBlock(PtXYZ, BlockName, ValScale, ValScale, ValScale, ARotation) ' HERE IS THE PROBLEM

'If Acad_BlockInsert.HasAttributes Then

'ArrayATT = Acad_BlockInsert.GetAttributes

'....

'....

Next I

Catch ex AsException

' I got this error number 91 and it meant that object reference not set to an instance of an object

MsgBox("Error número "& Err.Number & vbNewLine & "Descripción del Error: "& Err.Description)

 

EndTry

 

Catch ex AsException

If Err.Number = 429 Then

MsgBox("AutoCAD no se encuentra activada o el programa no esta instalado en el EQUIPO", MsgBoxStyle.Critical, "ERROR DE CONEXION (EXCEL - AUTOCAD)")

EndIf

EndTry

 

So, I can't insert the block because I got the err.number 91.

I would like to know if there will be some way to sort it out , or It's not posible to create this kind of connection between Excel and AutoCAD with VB.NET

 

I'll appreciate any help

 

Viewing all 1680 articles
Browse latest View live


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