Site Tools


This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:acadschemes [2015/09/14] (current)
Line 1: Line 1:
 +====== List AutoCAD Export Schemes ======
 +> **Developer:​** //​[[developer:​rhinoscript|RhinoScript]]//​
 +> **Summary:​** //​Demonstrates how to build a list of ""​AutoCAD""​ export schemes.//
 +I would like to have a method which could return the AutoCAD DWG and DXF export schemes. This way, one could query the available schemes, present the user with a pick box and then set the desired scheme.
 +AutoCAD DWG and DXF export schemes are stored in the Windows Registry. The following sample code demonstrates how to build a list of them. Note, the "​Default"​ scheme is built into the AutoCAD export plug-in. Thus, if you want to list the "​Default"​ scheme, along with the custom schemes, you will to add this to the list of schemes yourself.
 +<code vb>
 +Option Explicit
 +  ​
 +Function GetAcadExportSchemes()
 +  Const HKEY_CURRENT_USER = &​H80000001
 +    ​
 +  Dim objReg, strComputer,​ strKey, arrSubKeys
 +  strComputer = "​."​
 +  strKey = "​Software\McNeel\Rhinoceros\4.0\Scheme:​ Default\Plug-ins\39a88493-9e97-4f15-bd62-ad25896a2632\Settings"​
 +  ​
 +  On Error Resume Next   
 +  Set objReg = GetObject("​winmgmts:​{impersonationLevel=impersonate}!\\"​ & strComputer & "​\root\default:​StdRegProv"​)
 +  If Err.Number = 0 Then
 +    Call objReg.EnumKey(HKEY_CURRENT_USER,​ strKey, arrSubKeys)
 +  End If
 +    ​
 +  If IsArray(arrSubKeys) Then
 +    GetAcadExportSchemes = Rhino.SortStrings(arrSubKeys)
 +  Else
 +    GetAcadExportSchemes = Null
 +  End If
 +    ​
 +End Function
 +</​code>  ​
 +You can test the function above with the following subroutine.
 +<code vb>
 +Sub ListAcadSchemes()
 +  Dim arrSubKeys, strSubKey
 +  arrSubKeys = GetAcadExportSchemes()
 +  If IsArray(arrSubKeys) Then
 +    For Each strSubKey In arrSubKeys
 +      Call Rhino.Print(strSubKey)
 +    Next
 +  End If  ​
 +End Sub
 +{{tag>​Developer RhinoScript}}
developer/scriptsamples/acadschemes.txt ยท Last modified: 2015/09/14 (external edit)