AutoCAD Customization
Accessing Data from an AcDbScale Object
I'm stuck! I can't seem to figure out how to access the information stored with an AcDbScale object using Visual Lisp. I can convert the vla-object to an ename and then use association codes to extract the data, but surely there's an easier, more direct alternative.
Thanks for any help.
J Leavitt
set bylayer lisp routine wont execute properly
Hi guys, me and a friend are trying to work on a LISP routine to select objects in a drawing and change their attributes to "ByLayer" and other things. He is a familiar with the AutoCAD commands, I have a general idea of how to use LISP and we're trying to put our heads together to solve some workflow issues at our job.
Thanks in advance for any help,
-aDiagram
(defun c:set23 () (setq uecho (getvar "cmdecho")) (setvar "cmdecho" 0) (command "setbylayer" "al" "" "n" "y") (command "-layer" "c" "23" "*") (command "-xref" "d" "*") (command "-purge" "al" "" "*" "n") (setvar "cmdecho" uecho) (princ) )
Change attribute color/layer per one block only
Hello!
I've read this post:
http://through-the-interface.typepad.com/through_the_interface/2007/02/changing_the_co.html
Everything works fine, but I have one problem.
I just want to change colors for all objects in current model space. But this command also changes attributes/blocks definitions (I mean, any new block which I insert has the color that I specified previous).
Why? Where I have to change the code?
AModeler library and thread safety
Hello. I want to know if the AModeler library is thread safe (the documentation says nothing about this). Inspecting the headers, I found a bunch of global variables used for floating point comparisons, so these are not thread safe (files epsilon.h, global.h). Are the member functions of the classes and the rest of the non-member functions in the library reentrant ?
How to define OPM property tooltip description?
Hi,
I'd like to define a custom OPM tooltip description like this:
I was able to define a custom name by implementing STDMETHOD(GetDisplayName)(DISPID dispId, BSTR *propName). Is there an equivalent for description? I tried to use a string resource ID as the first argument of OPMPROP_ENTRY but it didn't work (all SDK samples begin with OPMPROP_ENTRY(0, ...)).
Regards,
Jonathan
"Select All" in Macro
I have what I hope is a quick question..
Trying to add this macro to a new command in my cui. Does Select all not work in macros?
^C^Clayiso;\;_select;all;;_chprop;la;c-rway-x;;
Thanks in advance!
How to ddd external references in the drawing? (C#)
Hello, I want to load the external references in the drawing, how to implement this program?
I returned to the drawing path and the way I want to load it using the insertion point.
The code error is probably somewhere not understand where.
Please help )
[CommandMethod("TDMSXREF", CommandFlags.Session)]
publicvoid TDMSXREF()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
string path = "0";
string moduleName = "CMD_SYSLIB";
string functionName = "CheckOutSelObj";
TDMSApplication tdmsAppDlg = newTDMSApplication();
//path = tdmsAppDlg.ExecuteScript(moduleName, functionName);
ObjectId xrefObj = db.AttachXref(@"C\MyD.dwg", "test");
BlockReference br = newBlockReference(newPoint3d(0, 0, 0), xrefObj);
BlockTable btTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(btTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
modelSpace.AppendEntity(br);
tr.AddNewlyCreatedDBObject(br, true);
ed.WriteMessage(path);
}
tr.Commit();
}
struck with problem while.
Dear all,
I am just a begineer for auto lisp. I wrote my first program thanks to afra lisp, but got struck, I am unable to get out from while loop if i Press "enter". Please find the program below.
(defun c:arsh ()
(while
(setq p1 (getpoint "\n pick point :"))
(setq l 1500)
(setvar "osmode" 0)
(initget 7)
(setq p2 (polar p1 (dtr 0) l))
(initget 7)
(setq p3 (polar p2 (dtr 270) (/ l 2)))
(initget 7)
(setq p4 (polar p3 (dtr 180) l))
(command "line" p1 p2 p3 p4 "c")
(setvar "osmode" 111)
); end of while
(princ)
)
if any one could help me
Export drawing attributes to a MySQL server
My problem: I need to extract attributes from CAD files and export the data into MySQL type databases in order to compare the CAD data with other database data. Ideally the task needs to be done with a routine script that processes large sets of CAD files and data.
I would like to know:
- Can this be done?
- Whats the best way to script this or code this with an API?
- Has anyone done anything similar before?
- Is there a way to run this script on a server machine without AutoCAD installed? (Not that I'm trying to avoid using AutoCAD in general, of course the program was used to create the files, it just seems silly to install it on a server for one task)
- Is this script relatiavely simple, or would it require large amounts of time and/or an expert?
Thank you, any leads would be appreciated.
It appears that the visual basic database is timing out?
First things first ... this is my first experience with this forum and I'm not a programmer but placed in a position to find out why things are not working correctly. Our estimating department uses many VBA programs written for AutoCAD 2007 & 2008 Windows XP 32 bit. We are currently running AutoCAD 2013 Windows 7 64 bit. I was able to get all of their programs to work as they did in the older versions but have been having trouble with one in particular. It appears that after initiating a VB program the user has only a short time to fill out a form that eventually saves information out to a text file to be used later. The following is a list of observations I've uncovered:
- Once the macro is loaded and running, you don’t have to add or make changes for the sake of this example.
- Every once in a while hitting the Save Form Information button produces the expected results. The form remains active and more information can be added though at some point hitting the button will cause the form to disappear. That’s when it has crashed/timed-out and any information that was supposed to be saved was not.
- On my station and several others any action to Save Form Information after exactly 300 seconds will crash yet on others it happens after 60 or even 180 seconds consistantly for each user.
- One thing to note, if the Save Form Information is not clicked the program will appear 'not' to have failed for an undetermined length of time though it has, it just won’t disappear until you click Save.
- Once it disappears I’ve found that it has not unloaded as it should have.
- By re-initiating the macro it appears to actually unload it therefore clearing it from the loaded projects. Then hitting the button on the toolbar again it reloads the project from the last valid save.
Does anybody have any ideas why this is occuring? Also, as I stated before, I've been able to get all of the other programs to work. That is actually untrue as this issue occurs with all of them though this program is the only one that people keep open long enough for the timeout to affect their progress.
Thanks in advance to anyone daring enough to look into this issue.
; error: extra right paren on input
I was hoping for some help, I am going crazy trying to figure this out. In my acaddoc.lsp I have it load an autoload.lsp file that contains many lisp routines (attached). I am getting the "extra right paren on input" error. It appears to error after the third line in the autoload file "san18"....I removed everything after the third line and no error, I put them back and it errors and only loads first three? I can not see any issues??
Any help would be GREATLY appreciated. I am using Civil 3D 2014 and I have added all neccesary paths to the trusted locations.
Thanks Again...
LISP routine for level changes
Hi,
I used to a have a LISP for changing levels en masse if I needed to transform a survey by a certain factor. Unfortunately I've lost it. Does anyone happen to have one?
Cheers,
Ken
Ploting from Autocad
Hello,
I copy - paste the code used for plotting from the
AutoCAD .NET Developer's Guide - Plot from model space - works using as a printer: acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWF6 ePlot.pc3","ANSI_A_(8.50_x_11.00_Inches)") but when I change the line with:acPlSetVdr.SetPlotConfigurationName(acPlSet,"Oce TDS320", "Oce D+ 24x36 in")
it is not working. I have an error at this line.the Plotter I have is on the networkthe name is correct - as shown the Paper name is correct.see the snapshot of the control panel. What I am doing wrong here? ThanksMLEADERSTYLE class EnableLanding property
Hi,
I'm using .Net to create a MLeaderStyle in Autocad 2014. The problem is, the EnableLanding property exists on MLeaderStyle class but it doesn't apply it when it's created. The new style has Enable Landing always set to On even if I set it to false in .Net.
Any way I can set it to false via .Net?
Thank you,
Jean
Renaming xref....
Hi,
This lsp was passed on to me from a colleague but he doesn't know where he got it. It does a useful procedure of placing each xref, residing in the drawing, to a unique layer. The layer name is derived from the xref name. I would like to edit this to take only part of the xref name. This system I work with requires all files to have the job number as a prefix eg LE1399901_Contours.dwg, so the xref name would be LE1299901_Contours by default. I want to remove the first 10 characters to be left with "X_Xref-Contours" layer name using this code.
I have no idea how to achieve this so all help is appreciated.
thanks
Sean
(defun dxf (i a) (cdr (assoc i a)))
(defun c:lxr ( / ss cnt xrs en ed bn xp xbn )
(setq ss (ssget "x" '((0 . "INSERT"))))
(setq cnt 0)
(setq xrs (list))
(while (< cnt (sslength ss))
(setq en (ssname ss cnt))
(setq ed (entget en))
(setq bn (dxf 2 ed))
(if (/= 0 (logand 12 (dxf 70 (tblsearch "BLOCK" bn))))
(progn
(setq xp (dxf 1 (entget (tblobjname "block" bn))))
(setq xbn (strcat "X_Xref-" bn))
(command "-layer" "new" xbn "")
(vlax-put (vlax-ename->vla-object en) 'Layer xbn)
)
)
(setq cnt (1+ cnt))
)
(princ)
)
Ribbon - Unhandled access violation reading 0x0000 exception
Hi,
I have this Acad plugin (C#), where I simply create a Ribbon, Button on it that executes a Command.
Windows 7, AutoCAD 2013 all running x64.
Used the ObjectARX x64 Libraries for my references.
In my environment, everything works just fine, on my clients workstations... it shows 'Unhandled access violation reading 0x0000 exception'
Since client installed AutoCAD 2012 and then 2013, I tried a Repair, to no result.
Have verified all references, put all ObjectARX references, just to make sure, put debug lines in the code.
It crashes at first line:
Autodesk.Windows.RibbonControl ribbonControl = Autodesk.Windows.ComponentManager.Ribbon;
All other Commands seem to run just fine.
Any clue what could be the cause, what I could try more?
Conversion .dwg file to GDSII format
Hi Everyone,
Can anyone give me some hints how to convert a .dwg file into GDSII file?
Sample code in VB will be appreciated.
Regards
Zakir
remove all block attribute values.
Hi all,
I need a lisp sub-function that can empty all attributes of a specified dynamic block. The idea being that the specified block contains data that changes often and in order to repopulate the block's attributes with new data to replace the old I wish to just blank out the old data first, because it's possible that the new data may not utilize as many attributes and all of the old data must be removed.
The thing is the block I'm after is on several layouts, CTABs and they all need to be wiped clean.
Please and thank you :smileyhappy:
eNoInputFiler Error
After running the following code block, the drawing becomes unusable, as every time I run ReadDwgFile after a successful run I get "ENoInputFiler."
foreach (ObjectId attributeObjId in anotherBlkTableRecord)
{
AttributeDefinition attributeDefinition = (trans.GetObject(attributeObjId, OpenMode.ForRead).GetType() == typeof(AttributeDefinition) ?
(AttributeDefinition)trans.GetObject(attributeObjId, OpenMode.ForRead) : null);
if (attributeDefinition != null)
{
if (string.Compare(attributeDefinition.Prompt, attributePrompt, true) == 0)
{
return GetAttributeValueStep2(activeDb, workingBlock, attributeDefinition.Tag);
}
}
}
Am I doing something wrong?
pRegion->getAreaProp()
I want to let the user draw a complicated, 2D polyline, select it, and have it convert to a region so I can use the mass properties for a handful of tasks. I've gotten to the point (following the samples) where I am able to create the region using
es = AcDbRegion::createFromCurves(curveSegs, regions);
AcDbRegion *pRegion;
pRegion =static_cast<AcDbRegion*>(regions[0]); // I only have one element to pick
pRegion->getPlane(plane);
plane.getCoordSystem(origin, xAxis, yAxis);
es = pRegion->getAreaProp(origin, xAxis, yAxis, perimeter, area, centroid, momInertia,
prodInertia, prinMoments, prinAxes, radiiGyration, extentsLow, extentsHigh);
Then I save it to the database. It works fine up to this point, but I get the wrong centroid (and different than the command line "MASSPROP")
Anything obvious? Any help would be appreciated.
Thanks,
Ed
