Autodesk Plant Exchange

Community for Plant, Oil & Gas, and Natural Resources

Ask The Expert

Kean Walmsley Q&A

Profile Picture

About Kean Walmsley

Kean has been with Autodesk since 1995, focusing on providing programming support, consulting, training and evangelism to external developers. He has worked for Autodesk in a number of countries: he started his career in the UK and has (so far) moved every 2-3 years, working from Switzerland, the United States and India. He and his family have now settled back in Switzerland. Kean's current position is Senior Manager of Developer Technical Services (DevTech), the worldwide team of API gurus providing technical services through the Autodesk Developer Network.

Kean’s blog, Through the Interface, focuses on developing software to work with AutoCAD and other Autodesk platform products.

Expert Archive

Q&A

  • 09-28-2009 02:38amQuestion #1
    Hi Kean, Is there any way to prevent users to create their own layers and styles in AutoCAD?
    • September 28 2009Reply to Question #1
      Hi Edwin, Congratulations for being the first to ask a question! (and thanks for getting the ball rolling... :-) Looking at this from a programmatic perspective, AutoCAD has a number of events available via ObjectARX and its .NET interface that give rich information on when objects - whether visible drawing objects such as lines and circles or non-graphical objects such as layers and styles - get added to the drawing database. So you could certainly monitor when layers and styles are created by the user and take appropriate action. This could be "corrective", in the sense of the CAD Standards feature, which checks the names of symbol table records against predefined templates, or it could even be "destructive", in the sense of erasing these objects. Care would need to be taken to make sure the reason for the veto gets stated clearly, so as not to be disorientating for the user. I hope this helps, Kean
  • 09-28-2009 03:21amQuestion #2
    Hi Kean. I recently created a few C3D subassemblies. It took me much time to create files for the Content Browser, Toolpalette, Help and the asemblies. I am curious how this is done at Autodesk and what software to use.
    • September 28 2009Reply to Question #2
      Hi Adri, I'm unfortunately not an expert in C3D - and neither am I familiar with how we (at Autodesk) address this problem ourselves - but I can speak from my experience related to content generation in general. Companies that have a great deal of repetitive content to create - perhaps they have a large catalog of parts to generate on a regular basis, or perhaps they have a smaller number of pieces of "one-off" content to generate for multiple environments - often do invest in some kind of infrastructure to automate the process. There's usually a range of options available, whether developing a simple set of scripts to provide some modest task automation or investing in some complex system to crank out content based on records in a database. The various approaches tend to rely on the ability to programmatically create content, defining the appropriate parameters and rules/constraints. So back to where I started - I'm not aware specifically of what's possible with Civil 3D, whether via the previous COM API or the newly introduced .NET API - but I would hope that the resources available via the AutoCAD Civil 3D Developer Center (http://www.autodesk.com/developcivil) help clarify that. A good place to start is probably the DevTV session posted there. I hope this helps, Kean
  • 09-28-2009 05:53amQuestion #3
    Hello Kean, I have an add-on tool that I would like to write for AutoCAD Electrical. Overall my biggest question is within AutoCAD can I write data without attaching it to entities? I understand that I can use xData to write data to the drawing but if that entity get's erased out of the drawing for example I lose the data I wanted to write. I also don't want to write it to a file property because that would be too easy for a user to accidentally modify. Any advice would be helpful. Thanks and see you at AU.
    • September 28 2009Reply to Question #3
      Hello Rob, The preferred approach for storing your data in a drawing is to add it to the Named Objects Dictionary. We generally recommend creating your own custom company dictionary - pre-fixed with your Registered Developer Symbol go here to register your own symbol) to avoid name-clashes with other dictionaries - and then use that to store dictionaries for each of your products (a single dictionary can be used, of course - but it's always good to plan ahead :-). Within your per-product dictionary, you can place XRecords containing the data you wish to store. The overall approach is shown in this blog post. Yes - will be great to catch up at AU! Kean
  • 09-28-2009 08:31amQuestion #4
    Hi Kean, How do I use the WM_MDINEXT window message to prevent flicker while switching midi document windows in dotNet?
    • September 28 2009Reply to Question #4
      Hi Nathan, I'm assuming this in relation to this thread on the AUGI discussion forum. What you're doing seems almost correct - what I suspect you might be missing about the WM_MDINEXT message is that it's sent "to a multiple-document interface (MDI) client window to activate the next or previous child window." In the thread you seem to be sending it directly to the document you wish to activate. I haven't personally used this, myself, but I suggest experimenting with creating a few windows and sending different handles through, to see what effect it has (before coding something elaborate to handle this exhaustively. You might also ping Tony T to get more guidance, as this is his technique, from what I can tell. Good luck! Kean
  • 09-28-2009 08:45amQuestion #5
    Hi Kean, I created the following code below to maintain the current position while navigating documents: This works well in model space however I’d like to achieve this in paper space. Which objects could I use to achieve this? Also how could I prevent the UCS rotating out of a plan view when the UCS is rotated and still maintain the current position in model space I’m not sure why this happens… Hope you can help. Thanks. Imports AC_App = Autodesk.AutoCAD.ApplicationServices.Application Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.Geometry Imports Autodesk.AutoCAD.EditorInput Public Class FloorSurferView Private m_ptMax As Point3d Private m_ptMin As Point3d Public Sub New() SetMinMax() End Sub Private Sub SetMinMax() Dim acDoc As Document = AC_App.DocumentManager.MdiActiveDocument Using acView As ViewTableRecord = acDoc.Editor.GetCurrentView() Dim pCenter As Point3d = New Point3d(acView.CenterPoint.X, acView.CenterPoint.Y, 0) m_ptMin = New Point3d(pCenter.X - (acView.Width / 2), pCenter.Y - (acView.Height / 2), 0) m_ptMax = New Point3d(pCenter.X + (acView.Width / 2), pCenter.Y + (acView.Height / 2), 0) End Using End Sub Public Sub Zoom() If m_ptMin.Equals(New Point3d()) = True And m_ptMax.Equals(New Point3d()) = True Then Exit Sub End If Dim min2d As Point2d = New Point2d(m_ptMin.X, m_ptMin.Y) Dim max2d As Point2d = New Point2d(m_ptMax.X, m_ptMax.Y) Dim view As ViewTableRecord = New ViewTableRecord view.CenterPoint = (min2d + ((max2d - min2d) / 2)) view.Height = (max2d.Y - min2d.Y) view.Width = (max2d.X - min2d.X) AC_App.DocumentManager.MdiActiveDocument.Editor.SetCurrentView(view) End Sub Private ReadOnly Property Min() Get Return m_ptMin End Get End Property Private ReadOnly Property Max() Get Return m_ptMax End Get End Property End Class Private Sub Activate() View = New FloorSurferView 'Activate new document View.Zoom() End Sub
    • September 28 2009Reply to Question #5
      Hi Nathan, You might try looking at Database.Pextmin and Pextmax. These posts also includes some alternatives to setting the view directly. I'm not sure what's happening with your UCS: do you want the UCS to always remain "plan", even when the view has changed? That might be a little tricky to implement - I assume I'm misunderstood that point... One final comment: you can use Point3d.Origin rather than New Point3d(), and also the standard "=" operator, rather than EqualsTo(). Regards, Kean
  • 09-28-2009 09:43amQuestion #6
    Firstly, I want to tell you that I will be asking alot of seemingly simple questions. I have been moved to a position where I am expected to use CAD. Never used it before and I am trying to teach myself Autocad 2007 from a library book..... My problem today is that I am pulling up 2D images that I want to plot, but not all of the image is plotting. I have opened two layers (an architectural layer and a furniture layer), yet only one plots (furniture). How do I set it so that it plots all that I am looking at on the layout tab?
    • September 28 2009Reply to Question #6
      If you set the "Plot area" to "Extent" then you should be able to set the "Plot scale" to "Fit to paper". I'm not an AutoCAD power-user (my expertise is around programming/customization) but I'd hope that would work for you. Kean
  • 09-28-2009 10:45amQuestion #7
    I've been trying to deterime the bounds of an XReference. I can get the XrefGraph, from using a posting off of Through the Interface. That is a great site! I am using Autocad 2008 (Architectural) and can't figure out how to get the bounds of the XReference. I just need a min and max point in order to use those as a selection window to select all of the objects within the bounds of this XReference that fit the selection filter. The xreference is nothing more than a title block. Any help would be greatly appreciated.
    • September 28 2009Reply to Question #7
      Once you have a Database object for your Xref, you should be able to query Extmin and Extmax. These should be valid, assuming the drawing was created in the drawing editor (and even then it may work - I'm just being cautious :-). Thanks for the feedback on the blog, by the way! Kean
  • 09-28-2009 12:23pmQuestion #8
    Hi Kean. I have playing around with the overrule api in acad 2010 (.net) - transformation overrule in particular. It does not seem to catch all cases when an entity is being transformed, in particular when you drag an entity. Just simply drag it. Why is this? John.
    • September 28 2009Reply to Question #8
      Hi John, I hit a similar issue back when creating the code for this post. At the bottom of the page you'll find some explanation for the behaviour: "This is apparently due to optimization inside AutoCAD: during a recent discussion with our Engineering team I learned that during certain operations – such as when a modification to an object or set of objects can be represented by a standard transformation (such as scale, rotate or move) – AutoCAD captures the graphics of those objects and then performs a “sprite” optimization to move the object(s), rather than continually asking the object(s) to participate in the movement by drawing their own graphics or by transforming their internal state." Regards, Kean
  • 09-28-2009 02:24pmQuestion #9
    Hi Kean, I don't know if you can help me, but I'm looking for a DWG viewing component for WPF (Windows Presentation Foundation), or to be more precise, for Microsoft Surface. Do you know if I can find such a component somewhere? I would need to display DWG files on a MS Surface with reasonable speed (so http://www.woutware.com/cadlib3.5.html won't do I'm afraid). You help is much appreciated.
    • September 28 2009Reply to Question #9
      Hi Bart, There are four main options for integrating 2D/3D viewing components in your WPF application (and a fifth which is 3D only). All currently provide ActiveX controls for embedding, but should be usable with WPF. 1. DWG TrueView. This is only modestly customizable (very basic capabilities to drive zoom & plot and a few other bits & pieces. 2. AutoCAD OEM. This is the technology used to create both DWG TrueView and AutoCAD LT: a toolkit allowing you to stamp out non-extensible, custom-branded products that provide a subset of AutoCAD's capabilities. Great flexibility, but you do need to pay for it (and this is often prohibitive if developing a viewer rather than an editor). 3. RealDWG. This ia a DWG access toolkit that allows you to read in DWG files, but doesn't support viewing. You'd have to license a compatible viewing technology - such as HOOPS from Tech Soft 3d, which is pre-integrated with RealDWG - to make this work, and that would be a "low visual fidelity" option when comparing the graphics from this approach with those generated by applications using AutoCAD's graphics pipeline. 4. Design Review. This is where we move away somewhat from DWG-oriented workflows to use DWF. This implies some kind of conversion process - whether manual (e.g. plotting or publishing from AutoCAD to DWF) or automatic (e.g. some kind of on-the-fly or batch conversion process). But a much lighter-weight component, if that's a factor for you. 5. Navisworks. This is (to the best of my knowledge) a 3D-oriented technology whose driving principles are really quick performance and broad aggregation capabilities of different types of design data. The specific choice will depend a lot on what you're looking for. I'd start with 1 & 4 (both are free and easy to try). Regards, Kean
  • 09-28-2009 04:23pmQuestion #10
    Kean, just submitted a support ticket to ADN, but thought why not give this a shot as well :) How would you go about selecting an object from recreated objectid. Or better yet, how do you recreate an objectid? What information should I store? i'm limited to storing strings and numbers because the data is stored in xml format. I don't want to have to reitterate through the tablerecords everytime a user wants to make a change, so once I find the entity the first time, I want to store all vital information to retrieve the entity without reitterating again. Thanks, Viktor.
    • September 29 2009Reply to Question #10
      Viktor, This really depends on the lifetime of the data you want to store. ObjectIds are really transient values (you should think of them as pointers to memory locations) which can be saved to file but will get remapped automatically to new values when the file is loaded back in. So if you're working within a single editing session, then it's OK to think about storing them in-memory - creating an index, as you've described. But then I'm curious about the need to store the data in an XML format. If you actually need to persist these values, then you have to use Handles - which are easy to convert to ObjectIds using Database.GetObjectId(). I'd probably recommend going the route of handles, in this case, but if this is all temporary - and is always going to be temporary - then you can get the OldIdPtr property from ObjectId, store that long value in a string, and then you can simply recreate the ObjectId by passing that long value (decoded from your string) into the ObjectId constructor. Regards, Kean
  • 09-29-2009 04:39amQuestion #11
    Hi Kean. On the AU last year we talked briefly about the use of the available Linetype/ lineweight controls. I used them for several years in my VBA application. But when I rewrote my application in vb.net I could not use these controls in a Microsoft-property grid. Therefore I had to create them myself. Only the appearance of my linetype combo does not look nice because of the shapes in the complex linetypes. I just downloaded the ADN AutoCAD 2010 utilities but am afraid to install it while still fine tuning my current release on AutoCAD 2008/2009. Can I install the new controls safely and is there a readme available with improvements? Regards, Adri
    • September 29 2009Reply to Question #11
      Hi Adri, I don't think there's any real risk with installing these controls - as far as I'm aware the reason there's an installer at all is to register the ActiveX controls via COM, which shouldn't impact AutoCAD's behaviour at all. I don't think there was much done by way of "improvements" , although for sure we fixed any bugs that had been raised with the previous version. I would suggest giving it a try - be sure to let us know via DevHelp Online if you hit any issues (including any problems including the controls in the MS property grid). Regards, Kean
  • 09-29-2009 04:45amQuestion #12
    Hi Kean, I have made a small program that produces a cupboard in 3D, user have to enter some parameters(Height, Length, width, thickness) based on these parameters the program draw the cupboard. For each side I have to make a different solid and do some BooleanOperation to subtract other solids (holes) from that side. After the subtract I have to redraw the same solid and subtract this from other side. Is there a better way to program such a shape, or more efficient way?
    • September 29 2009Reply to Question #12
      Hi Anmar, That's an interesting question. My instinctive reaction is to wonder why you're not using Autodesk Inventor, which has a rich API that would allow you to drive content creation and make holes that know they are holes (rather than relying on unions and subtractions of solids in AutoCAD). But I'm sure you have your reasons. :-) Assuming that's the case... the way you're doing it is OK: short of implementing your own custom cupboard entity (which would be a great deal of work), what you're doing is reasonable enough. I can't think of a better way to achieve this if relying on standard, built-in AutoCAD drawing objects. Regards, Kean
  • 09-29-2009 08:09amQuestion #13
    Hi Kean, have what seems like a really simple customisaztion challange. would like to be able to search a drawing file for door and window codes that are in the wrong format and do a replace. The wrong code is in the form 001 001 to 999 999 and needs replacing with 001.001 to 999.999. So need to replace the space with a period. AutoLISP or VBA would be great.
    • September 29 2009Reply to Question #13
      Hi Andrew, Before going down the path of writing some custom code for this, have you checked to see whether you can get there using the standard FIND command? You can use wildcards, but a lot depends on your data, as to whether it's easy to search & replace. Worth asking the question, though. :-) Using LISP you could (ssget "X") on the object types you care about, and then loop through the selection set, calling (entget) and (entmod) on the various entities to update their contents. Should be fairly simple - I don't have any code ready to go, but you should be able to find something on the net (I did find a Toggle Text routine on this site, which looks like a great place to start). Regards, Kean
  • 09-29-2009 09:33amQuestion #14
    Hi, Kean While doing my own coding I seem to realize there is a limit on number of CommandMethod-defined autocad commands each DLL can contain. I say this because autocad does not recognize all my CommandMethod-defined autocad commands. Please confirm my thought. btw, my question is about vb.net
    • September 29 2009Reply to Question #14
      Hi Sam, That's interesting, but I'd be very surprised if there was a limit to the number of commands a DLL can contain: the .NET command registration mechanism simply collects the attributes and then loops through, registering the commands via ObjectARX. So - assuming there is a limit - it could be from one of two places: a) a hard-coded limit on the number of attributes, whether because of a fixed-size array being used to collect them (highly unlikely, knowing the programmer who implemented this) or some overall limitation in the number of attributes that can be used in .NET (also very unlikely), or b) a limit on the number of commands that can be registered via ObjectARX (not something I've ever heard of). A telling indicator might be the number of commands your DLL exposes: if it's a round number (and by "round" I mean it in the binary sense: 128, 256, 512...) then that would be a clue that there's an infrastructure problem. Another possibility might be more related to memory consumption, but again - not something I've really come across before. What typically happens if some kind of exception is thrown during load of an assembly is that the assembly doesn't get loaded, and no commands get registered at all. All in all, most puzzling! Perhaps you can follow up with some more information, such as the number of commands? Regards, Kean
  • 09-29-2009 10:01amQuestion #15
    Hi Kean, we have received some autocad files from a customer, since we use LT I open in auto2008 and save as 2000LT no problem. I want to extract some line forms to use as dxfs in my tool programming but when I copy and paste nothing comes out. The file is not marked as read only, is there something the customer did to inhibit extraction? If so can I get around it? These are complicated forms and redrawing would be a bite. I usually don't have any problems with others.
    • September 29 2009Reply to Question #15
      Hi Geoff, Hmm - that's tricky to know without looking at the DWG. The classic ways to protect data in AutoCAD are a) to lock it up in a custom object, which may also mean you're only seeing proxy graphics or b) to place entities on a locked layer. Do you have some indication of the types of object you're dealing with, and whether the layer they're on is locked? Regards, Kean
  • 09-29-2009 10:29amQuestion #16
    ie Q16 All appear as lines arcs and are editable in the drawing itaself can copy and paste to the same file. When picked to to copy tp clipboard it says it finds the correct # of objects. It just doesn't past to another file. The layer is not locked and I've made multipule copies in the same file.
    • September 29 2009Reply to Question #16
      Have you tried copying to other, blank files, or is it just the one destination file that's a problem? Kean
  • 09-29-2009 10:44amQuestion #17
    I have downloaded the October Plugin and followed the Installation Instruction. But It is not working. I'm using 2010 Mechanical. The program does not seem to load. What other steps should I take with this add on. Thanks, Robert
    • September 29 2009Reply to Question #17
      Hi Robert, I've had a similar report from someone using Civil 3D, and I'm working with them to identify the problem (it works fine from our side). We should probably handle this one by email: if you're able to edit/build the application source then you might try commenting out the call to automatically register the application for demand loading (it's in the Initialize() function in Clipboard.vb). It's just possible that on certain machines that are locked down, there might be an exception that I'm failing to catch (which would abort the load process). That's still mainly speculation, at this stage, mind - let me know if it sounds like your problem... Regards, Kean
  • 09-29-2009 11:20amQuestion #18
    IeQ16: Thanks Kean you put me in the right direction, It doesn't copy in LT to any file but does copy in Autocad2008. I don't know why but I can work with it. Thanks
    • September 29 2009Reply to Question #18
      Great - glad to be of help, even if I didn't provide the answer. :-) Kean
  • 09-29-2009 11:45amQuestion #19
    I have been using AUTOCAD for 7yrs. and have been surveying for 5yrs. When I have to determine highway right-of-way control using the enginnering station numbers I run into problems!!! With my AUTOCAD I use Visisoft, an extention, so that I may prepare Land Surveys. My question is how do I compute the enginnering station numbers into AUTOCAD so that I may rebuild the highway right-of-way into AUTOCAD so I can overlay it onto my surveys.
    • September 29 2009Reply to Question #19
      Hi Michael, I'm afraid to say this is way outside my area of expertise. :-( I suggest you try posting your question either via your reseller, the Subscription Center (if you're on subscription), or to one of our online discussion groups. I'd also suggest looking into AutoCAD Civil 3D, if you haven't already, although I don't know how well this would meet your requirements. Regards, Kean
  • 09-29-2009 01:13pmQuestion #20
    I recently started running acad 2008 on win XP 64 and I have start up problems, my personel profile will not retain changes, my background color will not reset everytime I start up, my osnap settings reset, all in all it is not working correctly, what do you suggest?
    • September 29 2009Reply to Question #20
      Is it possible you have restricted Registry access on your machine? I also assume you're using the x64 version of AutoCAD 2008 (you may want to double-check that - I'm pretty sure the 32-bit version wouldn't have installed, in any case). Kean
  • 09-29-2009 01:53pmQuestion #21
    Hi Kean Do you know of a way to trim a horizontal stiffener when it attaches to a radius corner of a bulkhead?
    • September 29 2009Reply to Question #21
      Hi Philip, Sorry - I'm afraid I don't know enough about the domain you work in to be able to answer this question. My specialty is really related to programming with AutoCAD, I'm not familiar with design issues such as this. Regards, Kean
  • 09-29-2009 02:06pmQuestion #22
    Hi, I'm trying to install 'design review' on a mac via parallels and xp. For some reason design review cannot access the internet during the install and quits. the internet works fine in the xp environment otherwise. is this a known issue, or should i keep trying?
    • September 29 2009Reply to Question #22
      Hi Joseph, I don't see Design Review as one of the products we now support via Parallels on the Mac. As a component of AutoCAD, it should theoretically install and work, but I don't know about the standalone version. And as I don't personally use a Mac (at least, not yet ;-) it's not something I can easily verify or provide help with. Perhaps someone on the discussion groups has had more success? Regards, Kean
  • 09-29-2009 05:45pmQuestion #23
    it states that the driver is available i then click yes. Then it states performance tuner failed to update please check your network connection and make sure you have write permission to the file. please help
    • September 29 2009Reply to Question #23
      This isn't an issue I've come across, and there isn't really enough information for me to say what's happening. I suggest passing this one through existing support channels (your reseller, the Subscription Center if you're on subscription or the discussion groups). Kean
  • 09-29-2009 05:56pmQuestion #24
    Hello Kean, my name is Malcolm I have been reading some of the questions people have been asking and may have some answers to them as I have faced the same problems. how would I go about suggesting some answers to other people who have asked you questions? I am not an expert by any means, I have only been using CAD for about a year but would like to try and help.
    • September 29 2009Reply to Question #24
      Hello Malcolm, The forum seems to be set up for one to many (not many to many) communication, so I don't know how this would work. One thing I would suggest to anyone not getting their questions answered here: please go ahead and ask them again on the appropriate discussion group and people such as Malcolm can then help with comments from their own experience. Kean
  • 09-29-2009 06:53pmQuestion #25
    Kean, thanks for your previous reply. One other question. If you're reading drawing data without opening in editor, is there a better way to select all entities on certain layer without going through the blocktables and testing each entity? I know (thanks to your blog) that if its open in editor you could select using dxfcodes, but that doesn't work without editor, right?
    • September 29 2009Reply to Question #25
      Viktor, Right: unless the drawing is open in the editor you are quite limited in terms of selection capabilities. Iterating through the various spaces is really the only way to go, that I'm aware of, unless you're maintaining and storing your own persistent index to speed this up (which is likely to be more work than it's worth - such object iteration is often pretty quick, even on large drawings). Regards, Kean
  • 09-30-2009 04:37amQuestion #26
    Hi, Kean, What are the Lisp program available in Auto Cad LT?
    • September 30 2009Reply to Question #26
      Hi Prem, AutoCAd LT does not support the execution of LISP applications (aside from those built in to the core of the product). The same is true of all APIs: one of the core differences between AutoCAD LT and AutoCAD is the powerful extensibility the latter provides. Regards, Kean
  • 09-30-2009 05:16amQuestion #27
    I am using AutoCAD 2009 how can I show the cordinates of each point in a drawing by any easy method?
    • September 30 2009Reply to Question #27
      There's lots of ways to do it programmatically: any of our APIs will allow you to iterate through the modelspace and get the points. Here's a little snippet of LISP you can paste to the command-line which will list them all, for instance: (setq i -1 ss (ssget "X" '((0 . "POINT")))) (while (setq e (ssname ss (setq i (1+ i))))(setq pt (assoc 10 (entget e)))(terpri)(princ (strcat "X: " (rtos (cadr pt)) ", Y: " (rtos (caddr pt)) ", Z: " (rtos (cadddr pt))))(princ)) Regards, Kean
  • 09-30-2009 09:05amQuestion #28
    Kean, how can I have my event handlers registered with Autocad when the module is loaded, without running a command. I have the module registered with Autocad in the registry, I want the event handlers to be registered when Autocad loads without having any user input, such as running a command to initialize them. Is this possible? Is there something other than CommandMethod that could run a command automatically at load time? Thanks.
    • September 30 2009Reply to Question #28
      William, You can derive an application class from IExtensionApplication and implement the Initialize() and Terminate() methods, as shown in this blog post (as it's not possible to unload .NET assemblies, the Terminate() will only be called on AutoCAD exit). If you want to optimize the loading of your application - if your assembly is particularly large/complex - you may also find this post of interest. Regards, Kean
  • 09-30-2009 09:55amQuestion #29
    Kean, I am using AutoCAD 2010. If I create a new viewport in a layout, all layers are automatically frozen in that layout, except for layer 0. I have to thaw all layers manually to see anything. Is there a setting or system variable to change this? Thanks
    • September 30 2009Reply to Question #29
      Burkhard, I don't see the behaviour you've described when I create a new paperspace viewport. Is it possible you have Layer State overrides being applied to the current viewport? Try selecting the viewport and running the LAYERSTATE command. There may well be something else in play, here, but this would be my first (and probably best) guess. Regards, Kean
  • 09-30-2009 12:01pmQuestion #30
    can't seem to create a custom linetype in 2010, can you help? Thanks
    • September 30 2009Reply to Question #30
      Are you trying to load a linetype in from a custom definition in a .LIN file? This should work just fine in 2010. In case you want to do this programmatically, this blog post may be of interest to you. Regards, Kean
  • 09-30-2009 12:02pmQuestion #31
    Hi, Kean, i sent you a questoin yesterday about limits on number of CommandMethod defined Autocad commands. I have confirmed with testing that it seems there is a limit on number of sub routines or commandMethod defined acad commands in vb.net 2008 express edition. I found where the cut was. Before the cut, commands can be recognized, and after the cut, no commandMethod defined acad commands work. If I move the non working commands forward to an earlier class within the same VB project, the command works. Best regards
    • September 30 2009Reply to Question #31
      Hi Sam, In the meantime I've also checked with Engineering: they know of no limit that would be imposed on the number of commands, other than the physical memory of the machine or the number that can be held by an integer variable (which is *huge*). How many commands are you defining? Have you found the same "cut-off" on different machines? One other question - are you using the approach in this blog post to identify your command classes? It is optional, but may help. Regards, Kean
  • 09-30-2009 12:11pmQuestion #32
    comment apprendre et connaitre autocad architecture 3D
    • September 30 2009Reply to Question #32
      Tout dépend de votre préférence en matière d’apprentissage. Il existe un tutoriel dans le produit lui-même, mais sinon je conseillerais de rechercher les «Authorised Training Centres» dans votre région: www.autodesk.com/atc. Sincèrement, Kean
  • 09-30-2009 12:32pmQuestion #33
    Kean, I would like to thank you for doing this Q&A. It has bene extremely helpful, as this is my third question already. I am opening a document from a string passed. The document opens fine. I then fill a selection filter and pass it to this Editor.SelectWindow(pt1, pt2, sf). It is throwing a eNotApplicable error and I can't understand why? If you could point me in the right direction that would be great. Once again thanks for taking the time here, your input has been invaluable.
    • September 30 2009Reply to Question #33
      William, It's my pleasure - it's nice to know it's been of use. Are you attempting to select entities in the same command that opened the drawing (which would presumably need to be a "session context" command)? You may be hitting document locking issues, if that's the case. It may actually be safer to launch your selection command in the newly opened document using Document.SendStringToExecute(), which will cause the locking to be taken care of automatically (assuming it's a modal command). And just to be sure it's not related to the construction of the filter string, I assume you've seen this blog post. Oh, and feel free to keep the questions coming. :-) Kean
  • 09-30-2009 12:49pmQuestion #34
    Hello Kean, I've been working on a project in my company for some time the problem is I'm a CAD monkey and not a programmer... We're trying to take our files from AutoCAD, apply materials to them, and export a file for the web. The problem is we want to automate it. Do you have any ideas or suggestions?
    • September 30 2009Reply to Question #34
      Hello Eric, Automating the export to a particular web-friendly file format (such as via the PNGOUT command, if going to 2D raster, or -PUBLISH, if wanting a 3D DWF) is typically easy enough to script at the command level for non-programmers (using a standard .scr file via the SCRIPT command): the trick is likely to be applying materials to objects (unless you actually mean loading materials?). If applying materials, some logic or user-selection will be needed, which tends to add a dimension to the scripting challenge. Regards, Kean
  • 09-30-2009 01:09pmQuestion #35
    hi there, i need to demonstrate a 3d model for a cliant tomorrow, but dont have a model. i have tried to find a model of a auditorium, church or sports facility but without any luck... do you have any posebillity to send me sutch a dwg file? best, jorgen my mail is, jorgen_allen@bose.com
    • September 30 2009Reply to Question #35
      Hi Jörgen, I don't have any such models myself, but you might find something out there on the web, if you search for it with the right keywords. Regards, Kean
  • 09-30-2009 01:52pmQuestion #36
    ObjectArX: How can I get the list of all the loaded LSP, VLX, VBA applications as in the window of APPLOAD command?
    • September 30 2009Reply to Question #36
      Nice to hear from you, Nikolay! :-) You can hopefully find the commands registered by loaded VLX apps via the AcEdCommandStack (retrieved using the acedRegCmds macro), but I don't think that will give you LSP and VBA. And it may well not give you module info on the VLX files, thinking about it. This is probably a good one to ask via ADN, knowing that you're a member (sorry to be ducking that one - my suspicion is that it's not available via ObjectARX, but someone on my team will confirm). Regards, Kean
  • 09-30-2009 03:26pmQuestion #37
    Would like to switch between documents by clicking on its associated tab. Is this possible in 2010?
    • September 30 2009Reply to Question #37
      Hi Jack, There's a bonus tool available here to enable this for AutoCAD 2007-2010. Regards, Kean
  • 09-30-2009 05:22pmQuestion #39
    How can I get Impression 2 to add color and patterns to 2D plans the same way M-Color does. I just can't find the simplicity in the software.
    • October 01 2009Reply to Question #39
      It's been some time since I've used Impression and I unfortunately don't have any experience with M-Color, so I'm probably not the right person to try to answer this question. You may have more luck on the Autodesk Impression Discussion Group. Regards, Kean
  • 09-30-2009 05:22pmQuestion #40
    Hi Kean I know this should probably be reported as an ADN request, but seeing as you're available right now, here goes. The .NET Database.SaveAs method has been broken in the AutoCAD 2010 API. Up until 2009, it would always change the current document name to the new file name. This is logical, and what you expect a Save As to to do in any program. 2010 has a new overload accepting (string fileName, bool bBakAndRename, DwgVersion version, SecurityParameters security). The original method accepting only fileName and version should behave as it always did, by calling the new method and passing true for bBakAndRename. It doesn't. This must be a bug, because if you're going to overload a method you shouldn't break the existing methods. This was a real pain to debug, and now I have to maintain two forked versions of our software, for something that should never have happened in the first place. Regards Michael
    • October 01 2009Reply to Question #40
      Hi Michael, From what I can tell, this appears to be an intentional change from our side. I do suggest submitting your question via ADN, as you've suggested, to get the full history of why the change was made - my suspicion is that there was some logic behind the change in behaviour of the original function version, but someone in my team will know more. Regards, Kean
  • 10-01-2009 03:57amQuestion #41
    hi, i have probelm every time i open the my file it show me test on the middle must re_cover , i try many method but still same problem,
    • October 01 2009Reply to Question #41
      Your best bet is probably to use the RECOVER command in the most recent release of AutoCAD you have access to (as this tends to get improved as we come across more examples of drawing corruption). Regards, Kean
  • 10-01-2009 06:46amQuestion #42
    Hi Kean, i am trying to develop a dynamic block with stretch and array functionality. I want the user to stretch the object to the desired size then array this shape. The array action requires a numeric column offset distance, but I need this to be dependant on the stretching that has occured. Is there a way to do this? Thanks.
    • October 01 2009Reply to Question #42
      Hi Stephen, Are you using AutoCAD 2010, by any chance? I'm pretty sure that the parametric constraints introduced in that release will be valuable to you as you attempt this. Although admittedly I haven't actually attempted something like this myself. Regards, Kean
  • 10-01-2009 08:55amQuestion #43
    Kean, I have started to convert my vba to vb.net. Previously I used Objectdbx to cycle through all the .dwg files in a directory (user specified) and then export certain data from blocks. Is there a good way to silently cycle though files in a directory and gather data using .net? Thanks in advance, Justin
    • October 01 2009Reply to Question #43
      Justin, Absolutely. I think you'll find this blog post useful as a starting point. Regards, Kean
  • 10-01-2009 09:07amQuestion #44
    Hello Kean. I've been working on a tool to change a drawing's Xrefs to use relative paths. Database.GetHostDwgXrefGraph() returns a list of Xref'ed drawings but not Xref'ed TIFF images. How can I get a list of Xref'ed images?
    • October 01 2009Reply to Question #44
      Hello Diare, You would need to select the raster image objects in the modelspace and/or layouts you care about. Raster images are much simpler than XRefs as they can't be nested and therefore have no need for a graph to represent their relationships. The simplest way to select them from the modelspace would probably be to start with this blog post, reducing the conditions to be just on class and changing the class string to "IMAGE". Regards, Kean
  • 10-01-2009 10:10amQuestion #45
    As the format of AU is changing this year, I'm wondering if Process and Plant Industry is one of the 18 tracks offered. What classes and other events is P&P offering? I have not yet enrolled therefore can not see the courses. I'm just starting with P&ID and have attended in the past. I need info for added justification. Thanks.
  • 10-01-2009 11:14amQuestion #46
    Mr. Walmsley I work with 2010LT. I have piping blocks with attributes, a handful of the blocks are dynamic. Each block is on a tool palette. I have found that some blocks do not have the correct base point (at the endpoint). When I drag these from my tool palette I cannot connect them without having to drop them into the drawing and move them from the endpoint to their correct location. In the block editor, I have placed the base point in its correct location. The problem; when I drag the block from my tool palette into a drawing the base point is correct and I can connect the pipe, but the attributes do not stay next to it? They are off in the distance. When I edit the dynamic blocks, the opposite happens. The attributes follow the new base point, but the pipe does not. How do I redefine these blocks so that the base point follows the cursor to its correct location in the drawing, and the attributes remain next to the pipe?
    • October 01 2009Reply to Question #46
      Mr. Hahn, It's a little tricky to picture exactly what the problem is - and while I know how blocks are implemented and how to create/manipulate them programmatically, I wouldn't call myself a block expert - but I would start with looking at how the attributes (in the non-dynamic) block are defined, and look at adjusting their insertion point. The dynamic blocks, as you've mentioned, have a quite different behaviour, which I assume is down to a different problem (and I know less about dynamic blocks than I do about traditional ones, when it's all said and done). Regards, Kean
  • 10-01-2009 12:47pmQuestion #47
    Kean, I have a custom dimension that I have created by extending the Point3AngularDimension class. How can I have the dimension text update when a grip edit is moved, I'm using Autocad 2008? I could not find any Modified event of anything like that associated with this class. Thanks.
    • October 01 2009Reply to Question #47
      William, This sounds like a perfect problem to solve using Overrules... the only problem being they were introduced in AutoCAD 2010. In the absence of Overrules, you might use the Database.ObjectModified() event, although this would probably only fire at the end of the drag operation, once the modification was made on the database-resident dimension. Regards, Kean
  • 10-01-2009 02:15pmQuestion #48
    Kean, got one more for you :) Since many of us are coming from VBA world and not C++, are there good resources that would help us better understand how we can apply OOP for autocad development? Also, how to properly structure classes, how to use inherits etc, specially when dealing with UI's. For example, I often get confused on what should be a shared sub or function and what should be private or public. Sounds basic, but when I start to try and practice it in the project it gets tricky. Any links, resources would be appreciated.
    • October 01 2009Reply to Question #48
      Viktor, That's a great question, and one I actually have on my plate to address at some point. I have been doing some research in this area, and I have to say I've been pretty impressed with some of the resources I've found, such as Microsoft's Ramp Up - especially the Developer Basics module - and a site in the UK called Home and Learn. Although this investigation is far from complete: sometime next year I hope we'll publish a "curriculum for programmers", which developers (experienced or otherwise) can dip into, depending on their learning needs. Watch this space (well, my blog, at least :-). Regards, Kean
  • 10-01-2009 03:47pmQuestion #49
    I have worked AutoCad 6,7,8 and some solids. plus pro/e, ug, and catia. what would you say the learning curve would be to inventor. thanks, athens
    • October 01 2009Reply to Question #49
      It sounds like you have the fundamentals in 3D modeling... at its inception Inventor had the concept of "single day productivity" at its core, and although the product has evolved, over time, I don't believe the fundamental focus on ease of use has changed. I'd suggest downloading and running the 30-day trial version - working through the product tutorial - to see how you get on. Regards, Kean
  • 10-01-2009 04:00pmQuestion #50
    Hi Kean. First of, Thanks for a great blog! I have been doing some helper apps to ease my daily work and have been using AutoCad 2009 so far. Soon we are going to start using 2010 and I am wondering if there is a database inspector available for 2010 aswell? Have done some searching but havn´t found anything yet.
    • October 01 2009Reply to Question #50
      Hi Johan, Thanks - I enjoy blogging a great deal, but it's still nice to hear when it's appreciated. I do have a 2010 version of the Inspector tool available: please send me an email (you can find my email address here, if you don't already have it) and I'll send it to you. Regards, Kean
  • 10-01-2009 04:59pmQuestion #51
    Iv just started back to school after 30 years and am taking and using AutoCAD Inventor Professional 2008, Iv also just bought a laptop with Vista on it and I can not get the Mechanial 2008 to load! HELP!!!
    • October 02 2009Reply to Question #51
      I really have no way of knowing what help you need here, I'm afraid. I suggest posting more information about your problem to the AutoCAD Mechanical Discussion Group, to see if someone there can help you. Regards, Kean
  • 10-01-2009 05:18pmQuestion #52
    Hello, I am trying to write a lisp routine which allows me to copy an object. I need to set my copy displacement values as wdth,0 where wdth is a variable calculated earlier in my routine. I don’t seem to be able to enter these numbers without an unwanted ENTER taking place before the 0 thus ending the copy command prematurely. The offending line of code is as follows: (command "._copy" "l" "" "" wdth "0") Is there a way I can stop ENTER being hit after the wdth variable appears? Thanks.
    • October 02 2009Reply to Question #52
      Hello Stephen, Assuming wdth is a decimal number of some kind (a "real") the simplest thing to do is to create a string from it (using (rtos)) and concatenate it (using (strcat)) with the string ",0": (command "._copy" "l" "" "" (strcat (rtos wdth) ",0")) Regards, Kean
  • 10-02-2009 08:33amQuestion #53
    Hi Kean, do you know what might cause AutoCAD 2010 to operate very slowly, especially when opening and plotting files? The screen will show "regenerating" for up to 5 minutes when plotting. We have to save all of our files down to the 2004 dwg format for users that have not upgraded, would it have anything to do with that? Thanks!
    • October 02 2009Reply to Question #53
      Hi Valerie, I'd suggest doing some performance tests with similar files in both 2004 and 2010 formats, to see whether there's a noticeable difference. One other suggestion is to try wblocking out your data, to see whether there's bloat due to additional data in the original files (such as RegApp table entries) that may be impacting performance. I hope this helps, Kean
  • 10-02-2009 10:19amQuestion #54
    I received and down loaded the 30 day trial disks and attempted to use tutorial getting started. The program would not recognise the sample drawing kitchens.dwg and I could not get anyone to help. HELP
    • October 02 2009Reply to Question #54
      Bill, Can I assume you're using the trial of AutoCAD 2010? This works when I attempt to use the OPEN command to load the Kitchens.dwg drawing on my system. You might try posting a complete description of the problem on one of our discussion groups, to see if someone there can help. Regards, Kean
  • 10-02-2009 10:29amQuestion #55
    I received and downloaded the 30mday trial disks. I want to potentially purchase this software. The trial disks will not bring up the requested sample files in tutorial 1, step three, kitchens.dwg. Also cannot get anyone to talk to. Frustrated Bill
    • October 02 2009Reply to Question #55
      Bill, My previous response was regarding the Kitchens.dwg in the AutoCAD 2010/Sample/DesignCenter folder. I also tracked down the online tutorial I suspect you're attempting to work through, and can confirm that the Kitchens.dwg file there also works in AutoCAD 2010 on my system. Regards, Kean
  • 10-02-2009 11:25amQuestion #56
    Kean: I just purchased AutoCad LT 2010 and noticed that the text in the title bat is black w. a ghost background. Is there a way to change the text to white to make it easier to read? Thanks.
    • October 02 2009Reply to Question #56
      Kenneth, I don't believe so: you can modify many of the system colours via the OPTIONS command (on the Display tab, under Windows Elements), but to the best of my knowledge these settings do not affect the title bar. Someone on the AutoCAD LT Discussion Group may know better, though. Regards, Kean
  • 10-02-2009 12:17pmQuestion #57
    Hi Kean, A common task we do is take linework for a set of lot lines, and make all the closed shapes contained within as closed plines. We can do it by hand with BPoly, but would like to select all entites involved and have acad figure out the possible closed shapes (that do not enclose other shapes). Is there some API that helps with this? Its a common thing to do when setting up topologies too. thx
    • October 02 2009Reply to Question #57
      Hi James, Yes, we do hear that a lot. There isn't currently an API exposed to help with this (there is a "point containment" sample on the ADN site, if I recall correctly, but it's quite complex and would also need a lot of work to meet your requirements). This is high on our API wishlist for a future release. Regards, Kean
Autodesk | AutoCAD Exchange

Welcome

Autodesk | AutoCAD Exchange

To access this feature, you must be registered and signed in.

With your free registration, you can:

  • Ask the experts questions
  • Network with your peers
  • Participate in the design showcase
  • Stay informed with our monthly newsletter
  • And much more!