I'm quite new to .NET in AutoCAD, usual story, boss need somebody to do something, no time for trainings (yet), etc... so please, bare with me
Here is the story. in an Acad plug-in, I need to get the list of standards associated to the current drawing
So far, I've got:
Dim nod As DBDictionary = tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead) Dim id As ObjectId = nod.Item("AcStStandard")
I do get the object ID of the AcstStandard dictinary. So far so good
but then ???
Can't seem to find an object type to do the tr.GetObject(id, OpenMode.ForRead)
There's stuff for layouts etc... but not for standards.
Solved! Go to Solution.
Something like this may helps
Dim nod As DBDictionary = tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead)
Dim id As ObjectId = nod.Item("AcStStandard")
Dim dict as DBDictionary= tr.Getobject(id, OpenMode.ForRead)
Not tested though....
Actually, I've got another one, related
Once I've done that, I get an xRecord with the data with the file name. The thing is that it's the original file path when the CAD standard file was attached.
However, it can (and it does happen alot with my users) that the files are moved around (the support path are changed in this case).
AutoCAd can resolve the new path from the support paths, however, I couldn't find any method to get this resolved path, do you know of one or do I have to loop thru all the support path and find the one i nwhich my file is found (with the risk that there might be multiple files with the same name in different paths, bad practicve I know but users....... ;-)
Do you want to get template file?
If so try this quick code:
Dim db As Database = HostApplicationServices.WorkingDatabase Dim newPath As String = HostApplicationServices.Current.FindFile("acadiso.
dwt", db, FindFileHint.Default) MsgBox(newPath)
Unfortunately, it gives me an eFilerError
thing is that the CAD standard file is not in any support path defined in the AutoCAD options, it is in the same path than the drawing itself.
I guess I´ll have to implement my own FindFile to include the drawing´s path in it. Thanx ofr the help anyways
Made my own stuff to look into the active drawing's path and in the support paths
Here it is, for those looking for a similar solution
' Takes a file name (without path) and returns the 1st dull file name (with path) in which the file is found ' Return empty string if not found
Private Function getPath(name As String) As String Dim Result As String = "" Dim sPath As String Try Console.WriteLine("Looking for " & name) ' Getting active drawing path sPath = New FileInfo(Application.DocumentManager.MdiActiveDocu
ment.Name).Directory.FullName Console.WriteLine(" in " & sPath) sPath = Path.Combine(sPath, name) If File.Exists(sPath) Then Result = sPath Console.WriteLine(" Found") return Result Else Console.WriteLine(" Not found") End If ' Getting all support paths in an array Dim pathPrefs As AcadPreferencesFiles = Application.Preferences.Files Dim supportPaths() As String = pathPrefs.SupportPath.Split(";") For Each sPath In supportPaths Console.WriteLine(" in " & sPath) sPath = Path.Combine(sPath, name) If File.Exists(sPath) Then Result = sPath Console.WriteLine(" Found") Return Result Else Console.WriteLine(" Not found") End If Next Catch ex As Exception Result="" System.Windows.Forms.MessageBox.Show(ex.ToString, "My App", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Stop) End Try Return Result End Function
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.