.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: variables set by -DWGUNITS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
For AutoCAD MAP(2008), see the AECDWGSETUP and -DWGUNITS commands
MEASUREMENT= 1
insunits=0
insunitsdefsource=0
insunitsdeftarget=0
ANNOTATIVEDWG=0
Other commands related
-dwgunits/-aecdwgunits
-EXPORTTOAUTOCAD
VBA code
for each blk ::Units =acInsertUnitsMillimeters
Change dxf code 70 from 1 to 0 in the dictionary AEC_Vars_Dwg_Setup.
(command "-DwgUnits" "3" "" "" "No" "No")
(defun set_dwgunits_to_no ( / dictionary_data_list)
(setq dictionary_data_list
(entget
(cdr
(assoc
350
(dictsearch (namedobjdict) "AEC_VARS")
)
)
)
)
(entmod
(subst
(cons 70 0)
(assoc 70 dictionary_data_list)
dictionary_data_list
)
)
(princ)
)
Re: variables set by -DWGUNITS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Can someone give a translation of this code in VB or C#?
(defun set_dwgunits_to_no ( / dictionary_data_list)
(setq dictionary_data_list
(entget
(cdr
(assoc
350
(dictsearch (namedobjdict) "AEC_VARS")
)
)
)
)
(entmod
(subst
(cons 70 0)
(assoc 70 dictionary_data_list)
dictionary_data_list
)
)
(princ)
)
Re: variables set by -DWGUNITS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
@Frank: Thank you for your time.
@Alexander: INSUNITSDEFSOURCE and INSUNITSDEFTARGET are not affecting the Units in DWGUNITS and UNITS.
@FritsA4: AECDWGSETUP and DWGUNITS are working for a opened drawing. i am looking for an option to change the value in the drawing database. i only want to load the database because of performance issues.
as i mentioned before running a lisp routine which opens every drawing is not a solution for 500 dwgs.
If i change my Drawing Unit from mm to Meter nothing changes in the dxf section you mentioned:
(entget (cdr (assoc 350 (dictsearch (namedobjdict) "AEC_VARS"))))
So does anyone know where the Value is stored to set the Units in DWGUNITS/AECDWGSETUP/UNITS to Meters/Millimeters etc?
Thank you,
regards,
max
Re: variables set by -DWGUNITS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Frank,
You wanted to get a translation from the LISP to VB.NET, what should I say, the codesippet you showed today morning does nothing on my pc/my Civil3D. However I could imagine what it should do: list all variables within a dictionary.
Look to my code, it takes the NOD, looks for a "AEC_VARS" item, goes through the collection of subobjects and list all the properties (name, type, value) from them. The output to a messagebox is quite ill because theres not enough place to show all properties from all records, you could change it to whatever you want, write a file or do just a debug-breakpoint and view it.
What you can see that for me in Civil3D I find a var "LinearUnit" within the item "AEC_VARS_DWG_SETUP", so my hope is you see it in your ACA also and at least you can modify it.
<Autodesk.AutoCAD.Runtime.CommandMethod("ADESK_lis tAecVars")> _
Public Shared Sub ADESK_getCivilUnits()
Dim tAcadDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim tAcadDocLock As DocumentLock = Nothing
Dim tTrAct As Transaction = Nothing
Dim tListAllVarsStr As String = ""
Try
tAcadDoc = Application.DocumentManager.MdiActiveDocument
tTrAct = tAcadDoc.TransactionManager.StartTransaction
Dim tNOD As DBDictionary = CType(tTrAct.GetObject(tAcadDoc.Database.NamedObje ctsDictionaryId, OpenMode.ForRead), DBDictionary)
If tNOD.Contains("AEC_VARS") Then
Dim tObjID As ObjectId = CType(tNOD.Item("AEC_VARS"), ObjectId)
If (tObjID.IsValid) AndAlso (Not tObjID.IsErased) Then
Dim tDBObj As DBDictionary = CType(tTrAct.GetObject(tObjID, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead ), DBDictionary)
If tDBObj.Count > 0 Then
Dim tEnum As DbDictionaryEnumerator = tDBObj.GetEnumerator
Do While tEnum.MoveNext
tListAllVarsStr &= "DbDict: " & tEnum.Key & vbNewLine
Dim tSubObj As DBObject = tTrAct.GetObject(tEnum.Value, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead )
tListAllVarsStr &= listProperties(tSubObj)
tListAllVarsStr &= vbNewLine
Loop
End If
Debug.Print("")
End If
End If
Call MsgBox(tListAllVarsStr)
Catch ex As Exception
MsgBox("Error occured" & vbNewLine & ex.Message)
Finally
If tTrAct IsNot Nothing Then tTrAct.Dispose() : tTrAct = Nothing
If tAcadDocLock IsNot Nothing Then tAcadDocLock.Dispose() : tAcadDocLock = Nothing
End Try
End Sub
''' <summary>listProperties does a MINIMAL listing of the property-values of an object
''' 'it does not evaluate any arrays, enumerations, subobjects, ...
''' </summary>
''' <param name="Obj"></param>
''' <returns>a string listing prop-name, prop-type, prop-value</returns>
''' <remarks></remarks>
Private Shared Function listProperties(ByVal Obj As Object) As String
Dim tRetVal As String = ""
If Obj IsNot Nothing Then
Dim tPropDefs() As PropertyInfo = Obj.GetType.GetProperties()
For Each tPropDef As PropertyInfo In tPropDefs
Dim tValStr As String = vbTab & tPropDef.Name & vbTab & "(" & tPropDef.PropertyType.FullName & "):" & vbTab
Try
Dim tVal As Object = tPropDef.GetValue(Obj, Nothing)
If tVal IsNot Nothing Then
tValStr &= tVal.ToString
Else
tValStr &= "<nothing>"
End If
Catch ex As Exception
tValStr &= "<error evaluating>"
End Try
tRetVal &= tValStr & vbNewLine
Next
End If
Return tRetVal
End Function
HTH, - alfred -
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Re: variables set by -DWGUNITS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Alfred,
Thanks very much. I think this will set me on the right track.
Regards, Frank
Re: variables set by -DWGUNITS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
dear all,
i found the drawin unit in the following variable in the drawings aec database:
using AECAPP = Autodesk.Aec.ApplicationServices;
public void testunit()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = HostApplicationServices.WorkingDatabase;
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
ObjectId objID = AECAPP.DrawingSetupVariables.GetInstance(db,false);
AECAPP.DrawingSetupVariables dsv = (AECAPP.DrawingSetupVariables)tr.GetObject(objID, OpenMode.ForWrite);
String from = dsv.LinearUnit.ToString();
String to = Autodesk.Aec.BuiltInUnit.Meter.ToString();
ed.WriteMessage("{0} to {1}.",from, to);
dsv.LinearUnit = Autodesk.Aec.BuiltInUnit.Meter;
tr.Commit();
}
}



