zhora Posted July 13, 2011 Share Posted July 13, 2011 Hi, Im really new to AutoCAD having always used so many different CAD packages before. Not too sure if this is posted in the right section but here I go: I'm trying to write a script that saves the filename to the properties when I select objects. E.g. I click on some lines and points. start the script. Then later when I click on any of those objects, I can see what the filename was in the properties panel. Its usually due to the fact we combine many objects from different files and I wish to know where they all came from initally. any help would be really appreciated. ~zhora Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 13, 2011 Share Posted July 13, 2011 Welcome to CADTutor, and congrats on your first post! It sounds to me like you're interested in adding an XData (AutoCAD all versions), or Object Data (Verticals like Map, Civil 3D) custom property to the selected objects that do not already have a value. I'm posting from my iPhone, but you can head over to the AutoLISP, Visual LISP & DCL forum for possible solutions. Quote Link to comment Share on other sites More sharing options...
Pablo Ferral Posted July 13, 2011 Share Posted July 13, 2011 You could look into Xreferences for a non API meathod, otherwise I think that Renderman has it bang on. Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 13, 2011 Share Posted July 13, 2011 You can set XData in Express Tools, or you can run a LISP or VBA routine (as RenderMan said) to give all entities in the drawing an XData item that is the name of the drawing. How would you deal with a new drawing in which you have imported entities from another drawing and have some new entities you created here? Would you want just the new entities to have the name of the new drawing and imported entities to have the name of their original drawing? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 13, 2011 Share Posted July 13, 2011 You can set XData in Express Tools, or you can run a LISP or VBA routine (as RenderMan said) to give all entities in the drawing an XData item that is the name of the drawing. How would you deal with a new drawing in which you have imported entities from another drawing and have some new entities you created here? Would you want just the new entities to have the name of the new drawing and imported entities to have the name of their original drawing? Presumably, and I could be wrong, reactor(s) could evaluate each entity added to the drawing's database, adding the above mentioned data where not already present. In this hypothetical scenario, copying objects from one drawing to another *should* retain the original data's value (from the source drawing)... Just thinking out loud. FWIW, that I see this as being a willful complication to an already complex process (i.e., Drafting, Data Management, Project Plans, etc.), and I personally would have no value from this being done for my projects. Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 13, 2011 Share Posted July 13, 2011 Presumably, and I could be wrong, reactor(s) could evaluate each entity added to the drawing's database, adding the above mentioned data where not already present. In this hypothetical scenario, copying objects from one drawing to another *should* retain the original data's value (from the source drawing)... Just thinking out loud. FWIW, that I see this as being a willful complication to an already complex process (i.e., Drafting, Data Management, Project Plans, etc.), and I personally would have no value from this being done for my projects. You are right, but I was just pointing out a problem. I wouldn't do anything like this too. As a solution you could loop through all entities in the drawing and if an entity doesn't have the XData then attach it (drawing name). Its not a problem in LISP or VBA or .NET :wink: (BTW how's .NET coming along?) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 13, 2011 Share Posted July 13, 2011 You are right, but I was just pointing out a problem. As a solution you could loop through all entities in the drawing and if an entity doesn't have the XData then attach it (drawing name). Its not a problem in LISP or VBA or .NET :wink: No worries, I only jumped to the reactor conclusion to account for all objects added during the drawing session. (BTW how's .NET coming along?) Thanks for asking, Tyke! I've cracked Visual Studio 2010 Express to launch Civil 3D, and debug properly, stopping at breakpoints, etc. (Eureka!), Snippet from .vbproj: ... <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> [color=blue] <StartAction>Program</StartAction>[/color] [color=blue] <StartProgram>C:\[/color][color=#ff0000]<FilePath>[/color][color=blue]\acad.exe</StartProgram>[/color] [i][color=black] ...[/color][/i] </PropertyGroup> ... I'm writing some basic 's in VB.NET and C#.NET, but have only began to experiment with scope of variables, stepping through selection sets, transactions, events, and creating custom tool palettes (populated by User Forms). I have several ideas for enhancements (which also include WPF), but the gap between my idea, and the know-how to make it come to fruition is expansive, to say the least. LoL Regardless of the decent aptitude I feel that I possess for Visual LISP (and I could be wrong?), I am quite literally a beginner with the .NET API. Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 13, 2011 Share Posted July 13, 2011 Its a long uphill struggle, but it sounds like you are going well. My problem is just a lack of time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.