En visual Lisp, on peut facilement trouver et modifier les propriétés de n'importe quel constituant d'un fichier autocad :
(vl-load-com) ; charge la bibliothèque des commandes étendues Visual Lisp
(setq acadobject (vlax-get-acad-object)) ; Connexion avec l'objet Application d'AutoCad.
Avec la commande VLAX-DUMP-OBJECT on peut obtenir la liste de l'ensemble des propriétés de chaque objet (y compris acadobject) :
(vlax-dump-object acadobject T) ; l'option T en fin de commande permet d'afficher également les méthodes.
affichage résultant :
; IAcadApplication: An instance of the AutoCAD application
; Valeurs de propriétés:
; ActiveDocument = #<VLA-OBJECT IAcadDocument 01b2cee8>
; Application (RO) = #<VLA-OBJECT IAcadApplication 00d73d3c>
; Caption (RO) = "AutoCAD 2008"
; Documents (RO) = #<VLA-OBJECT IAcadDocuments 10195980>
; FullName (RO) = "C:\\Program Files\\AutoCAD 2008\\acad.exe"
; Height = 1088
; HWND (RO) = 132236
; LocaleId (RO) = 1036
; MenuBar (RO) = #<VLA-OBJECT IAcadMenuBar 1023bd24>
; MenuGroups (RO) = #<VLA-OBJECT IAcadMenuGroups 01b00790>
; Name (RO) = "AutoCAD"
; Path (RO) = "C:\\Program Files\\AutoCAD 2008"
; Preferences (RO) = #<VLA-OBJECT IAcadPreferences 0bdc875c>
; StatusId (RO) = ...Contenu indexé masqué...
; VBE (RO) = #<VLA-OBJECT VBE 0f591844>
; Version (RO) = "17.1s (LMS Tech)"
; Visible = -1
; Width = 1928
; WindowLeft = -4
; WindowState = 3
; WindowTop = -4
; Méthodes prises en charge:
; Eval (1)
; GetAcadState ()
; GetInterfaceObject (1)
; ListArx ()
; LoadArx (1)
; LoadDVB (1)
; Quit ()
; RunMacro (1)
; UnloadArx (1)
; UnloadDVB (1)
; Update ()
; ZoomAll ()
; ZoomCenter (2)
; ZoomExtents ()
; ZoomPickWindow ()
; ZoomPrevious ()
; ZoomScaled (2)
; ZoomWindow (2)
T
; Valeurs de propriétés:
; ActiveDocument = #<VLA-OBJECT IAcadDocument 01b2cee8>
; Application (RO) = #<VLA-OBJECT IAcadApplication 00d73d3c>
; Caption (RO) = "AutoCAD 2008"
; Documents (RO) = #<VLA-OBJECT IAcadDocuments 10195980>
; FullName (RO) = "C:\\Program Files\\AutoCAD 2008\\acad.exe"
; Height = 1088
; HWND (RO) = 132236
; LocaleId (RO) = 1036
; MenuBar (RO) = #<VLA-OBJECT IAcadMenuBar 1023bd24>
; MenuGroups (RO) = #<VLA-OBJECT IAcadMenuGroups 01b00790>
; Name (RO) = "AutoCAD"
; Path (RO) = "C:\\Program Files\\AutoCAD 2008"
; Preferences (RO) = #<VLA-OBJECT IAcadPreferences 0bdc875c>
; StatusId (RO) = ...Contenu indexé masqué...
; VBE (RO) = #<VLA-OBJECT VBE 0f591844>
; Version (RO) = "17.1s (LMS Tech)"
; Visible = -1
; Width = 1928
; WindowLeft = -4
; WindowState = 3
; WindowTop = -4
; Méthodes prises en charge:
; Eval (1)
; GetAcadState ()
; GetInterfaceObject (1)
; ListArx ()
; LoadArx (1)
; LoadDVB (1)
; Quit ()
; RunMacro (1)
; UnloadArx (1)
; UnloadDVB (1)
; Update ()
; ZoomAll ()
; ZoomCenter (2)
; ZoomExtents ()
; ZoomPickWindow ()
; ZoomPrevious ()
; ZoomScaled (2)
; ZoomWindow (2)
T
Avec la commande VLA-GET-Nom_De_Propriété On pénètre dans une propriété en l'ouvrant comme un nouvel objet. Pour entrer dans le document actif, par exemple :
(setq activedocument (vla-get-activedocument acadobject))
pour voir : (vlax-dump-object activedocument)
affichage :
; IAcadDocument: An AutoCAD drawing
; Valeurs de propriétés:
; Active (RO) = -1
; ActiveDimStyle = #<VLA-OBJECT IAcadDimStyle 0bdc89b4>
; ActiveLayer = #<VLA-OBJECT IAcadLayer 0bdc8c84>
; ActiveLayout = #<VLA-OBJECT IAcadLayout 0bdc9454>
; ActiveLinetype = #<VLA-OBJECT IAcadLineType 0bdc8f04>
; ActiveMaterial = #<VLA-OBJECT IAcadMaterial 0bdc9044>
; ActivePViewport = AutoCAD: Aucune fenêtre active dans l'espace papier
; ActiveSelectionSet (RO) = #<VLA-OBJECT IAcadSelectionSet 10186fd4>
; ActiveSpace = 1
; ActiveTextStyle = #<VLA-OBJECT IAcadTextStyle 0bdc8c34>
; ActiveUCS = AutoCAD: Identificateur d’objet nul
; ActiveViewport = #<VLA-OBJECT IAcadViewport 0bdc8ff4>
; Application (RO) = #<VLA-OBJECT IAcadApplication 00d73d3c>
; Blocks (RO) = #<VLA-OBJECT IAcadBlocks 0bdc8874>
; Database (RO) = #<VLA-OBJECT IAcadDatabase 10182f54>
; Dictionaries (RO) = #<VLA-OBJECT IAcadDictionaries 0bdcada4>
; DimStyles (RO) = #<VLA-OBJECT IAcadDimStyles 0bdc8be4>
; ElevationModelSpace = 0.0
; ElevationPaperSpace = 0.0
; FileDependencies (RO) = #<VLA-OBJECT IAcadFileDependencies 10158aa4>
; FullName (RO) = "Z:\\_affaires\\1515\\Profil_en_long\\Marignan.dwg"
; Groups (RO) = #<VLA-OBJECT IAcadGroups 0bdc8a54>
; Height = 821
; HWND (RO) = 66868
; Layers (RO) = #<VLA-OBJECT IAcadLayers 0bdc7384>
; Layouts (RO) = #<VLA-OBJECT IAcadLayouts 0bdc8964>
; Limits = (-45975.4 -56134.1 67725.5 57566.8)
; Linetypes (RO) = #<VLA-OBJECT IAcadLineTypes 0bdc5df4>
; Materials (RO) = #<VLA-OBJECT IAcadMaterials 0bdca494>
; ModelSpace (RO) = #<VLA-OBJECT IAcadModelSpace2 0bdc5d54>
; MSpace = AutoCAD: Mode incorrect
; Name (RO) = "Marignan.dwg"
; ObjectSnapMode = 0
; PaperSpace (RO) = #<VLA-OBJECT IAcadPaperSpace2 0bdc5cb4>
; Path (RO) = "Z:\\_affaires\\1515\\Profil_en_long"
; PickfirstSelectionSet (RO) = #<VLA-OBJECT IAcadSelectionSet 10187124>
; Plot (RO) = #<VLA-OBJECT IAcadPlot 10157904>
; PlotConfigurations (RO) = #<VLA-OBJECT IAcadPlotConfigurations 0bdc5f84>
; Preferences (RO) = #<VLA-OBJECT IAcadDatabasePreferences 10158af4>
; ReadOnly (RO) = 0
; RegisteredApplications (RO) = #<VLA-OBJECT IAcadRegisteredApplications 12345678>
; Saved (RO) = 0
; SectionManager (RO) = Une exception s'est produite
; SelectionSets (RO) = #<VLA-OBJECT IAcadSelectionSets 014b1784>
; SummaryInfo (RO) = #<VLA-OBJECT IAcadSummaryInfo 10158b6c>
; TextStyles (RO) = #<VLA-OBJECT IAcadTextStyles 0bdc6a24>
; UserCoordinateSystems (RO) = #<VLA-OBJECT IAcadUCSs 0bdc69d4>
; Utility (RO) = #<VLA-OBJECT IAcadUtility 1023a064>
; Viewports (RO) = #<VLA-OBJECT IAcadViewports 0bdc6b64>
; Views (RO) = #<VLA-OBJECT IAcadViews 0bdc6894>
; Width = 1860
; WindowState = 1
; WindowTitle (RO) = "Z:\\_affaires\\1515\\Profil_en_long\\Marignan.dwg"
; Méthodes prises en charge:
; Activate ()
; AuditInfo (1)
; Close (2)
; CopyObjects (3)
; EndUndoMark ()
; Export (3)
; GetVariable (1)
; HandleToObject (1)
; Import (3)
; LoadShapeFile (1)
; New (1)
; ObjectIdToObject (1)
; Open (2)
; PurgeAll ()
; Regen (1)
; Save ()
; SaveAs (3)
; SendCommand (1)
; SetVariable (2)
; StartUndoMark ()
; Wblock (2)
T
; Valeurs de propriétés:
; Active (RO) = -1
; ActiveDimStyle = #<VLA-OBJECT IAcadDimStyle 0bdc89b4>
; ActiveLayer = #<VLA-OBJECT IAcadLayer 0bdc8c84>
; ActiveLayout = #<VLA-OBJECT IAcadLayout 0bdc9454>
; ActiveLinetype = #<VLA-OBJECT IAcadLineType 0bdc8f04>
; ActiveMaterial = #<VLA-OBJECT IAcadMaterial 0bdc9044>
; ActivePViewport = AutoCAD: Aucune fenêtre active dans l'espace papier
; ActiveSelectionSet (RO) = #<VLA-OBJECT IAcadSelectionSet 10186fd4>
; ActiveSpace = 1
; ActiveTextStyle = #<VLA-OBJECT IAcadTextStyle 0bdc8c34>
; ActiveUCS = AutoCAD: Identificateur d’objet nul
; ActiveViewport = #<VLA-OBJECT IAcadViewport 0bdc8ff4>
; Application (RO) = #<VLA-OBJECT IAcadApplication 00d73d3c>
; Blocks (RO) = #<VLA-OBJECT IAcadBlocks 0bdc8874>
; Database (RO) = #<VLA-OBJECT IAcadDatabase 10182f54>
; Dictionaries (RO) = #<VLA-OBJECT IAcadDictionaries 0bdcada4>
; DimStyles (RO) = #<VLA-OBJECT IAcadDimStyles 0bdc8be4>
; ElevationModelSpace = 0.0
; ElevationPaperSpace = 0.0
; FileDependencies (RO) = #<VLA-OBJECT IAcadFileDependencies 10158aa4>
; FullName (RO) = "Z:\\_affaires\\1515\\Profil_en_long\\Marignan.dwg"
; Groups (RO) = #<VLA-OBJECT IAcadGroups 0bdc8a54>
; Height = 821
; HWND (RO) = 66868
; Layers (RO) = #<VLA-OBJECT IAcadLayers 0bdc7384>
; Layouts (RO) = #<VLA-OBJECT IAcadLayouts 0bdc8964>
; Limits = (-45975.4 -56134.1 67725.5 57566.8)
; Linetypes (RO) = #<VLA-OBJECT IAcadLineTypes 0bdc5df4>
; Materials (RO) = #<VLA-OBJECT IAcadMaterials 0bdca494>
; ModelSpace (RO) = #<VLA-OBJECT IAcadModelSpace2 0bdc5d54>
; MSpace = AutoCAD: Mode incorrect
; Name (RO) = "Marignan.dwg"
; ObjectSnapMode = 0
; PaperSpace (RO) = #<VLA-OBJECT IAcadPaperSpace2 0bdc5cb4>
; Path (RO) = "Z:\\_affaires\\1515\\Profil_en_long"
; PickfirstSelectionSet (RO) = #<VLA-OBJECT IAcadSelectionSet 10187124>
; Plot (RO) = #<VLA-OBJECT IAcadPlot 10157904>
; PlotConfigurations (RO) = #<VLA-OBJECT IAcadPlotConfigurations 0bdc5f84>
; Preferences (RO) = #<VLA-OBJECT IAcadDatabasePreferences 10158af4>
; ReadOnly (RO) = 0
; RegisteredApplications (RO) = #<VLA-OBJECT IAcadRegisteredApplications 12345678>
; Saved (RO) = 0
; SectionManager (RO) = Une exception s'est produite
; SelectionSets (RO) = #<VLA-OBJECT IAcadSelectionSets 014b1784>
; SummaryInfo (RO) = #<VLA-OBJECT IAcadSummaryInfo 10158b6c>
; TextStyles (RO) = #<VLA-OBJECT IAcadTextStyles 0bdc6a24>
; UserCoordinateSystems (RO) = #<VLA-OBJECT IAcadUCSs 0bdc69d4>
; Utility (RO) = #<VLA-OBJECT IAcadUtility 1023a064>
; Viewports (RO) = #<VLA-OBJECT IAcadViewports 0bdc6b64>
; Views (RO) = #<VLA-OBJECT IAcadViews 0bdc6894>
; Width = 1860
; WindowState = 1
; WindowTitle (RO) = "Z:\\_affaires\\1515\\Profil_en_long\\Marignan.dwg"
; Méthodes prises en charge:
; Activate ()
; AuditInfo (1)
; Close (2)
; CopyObjects (3)
; EndUndoMark ()
; Export (3)
; GetVariable (1)
; HandleToObject (1)
; Import (3)
; LoadShapeFile (1)
; New (1)
; ObjectIdToObject (1)
; Open (2)
; PurgeAll ()
; Regen (1)
; Save ()
; SaveAs (3)
; SendCommand (1)
; SetVariable (2)
; StartUndoMark ()
; Wblock (2)
T
On voit, dans cette liste, que si l'on veut récupérer le nom du document il suffit de prendre le contenu de la propriété NAME :
(Setq NomDuPlan (vla-get-Name ActiveDocument))
"Marignan.dwg"
Et que, si l'on veut s'adresser aux propriétés des calques, on doit ouvrir un nouvel objet à partir de la propriété LAYERS
(Setq LayerTable (vla-get-Layers ActiveDocument))
pour voir : (vlax-dump-object LayerTable T)
affichage :
; IAcadLayers: L'ensemble de tous les calques du dessin
; Valeurs de propriétés:
; Application (RO) = #<VLA-OBJECT IAcadApplication 00d73d3c>
; Count (RO) = 140
; Document (RO) = #<VLA-OBJECT IAcadDocument 01b2cee8>
; Handle (RO) = "4C7B1"
; HasExtensionDictionary (RO) = -1
; ObjectID (RO) = 2126701768
; ObjectName (RO) = "AcDbLayerTable"
; OwnerID (RO) = 0
; Méthodes prises en charge:
; Add (1)
; Delete ()
; GenerateUsageData ()
; GetExtensionDictionary ()
; GetXData (3)
; Item (1)
; SetXData (2)
T
; Valeurs de propriétés:
; Application (RO) = #<VLA-OBJECT IAcadApplication 00d73d3c>
; Count (RO) = 140
; Document (RO) = #<VLA-OBJECT IAcadDocument 01b2cee8>
; Handle (RO) = "4C7B1"
; HasExtensionDictionary (RO) = -1
; ObjectID (RO) = 2126701768
; ObjectName (RO) = "AcDbLayerTable"
; OwnerID (RO) = 0
; Méthodes prises en charge:
; Add (1)
; Delete ()
; GenerateUsageData ()
; GetExtensionDictionary ()
; GetXData (3)
; Item (1)
; SetXData (2)
T
Pour entrer dans un calque en particulier on utilise la méthode ITEM de l'objet LayerTable :
(setq thelayer (vla-item layertable 72))
; On peut s'adresser à un calque par son numéro d'ordre : 72
; Mais également par son nom : "BATIMENT-HACHURES-DES-"
pour voir : (vlax-dump-object thelayer T)
affichage :
; IAcadLayer: Un groupe logique de données comparable à des feuilles
transparentes superposables sur un dessin
; Valeurs de propriétés:
; Application (RO) = #<VLA-OBJECT IAcadApplication 00d73d3c>
; Description = ""
; Document (RO) = #<VLA-OBJECT IAcadDocument 01b2cee8>
; Freeze = 0
; Handle (RO) = "4D270"
; HasExtensionDictionary (RO) = -1
; LayerOn = -1
; Linetype = "Continuous"
; Lineweight = 20
; Lock = 0
; Material = "Global"
; Name = "BATIMENT-HACHURES-DES-"
; ObjectID (RO) = 2126729280
; ObjectName (RO) = "AcDbLayerTableRecord"
; OwnerID (RO) = 2126701768
; PlotStyleName = "Color_8"
; Plottable = -1
; TrueColor = #<VLA-OBJECT IAcadAcCmColor 10187240>
; Used (RO) = 0
; ViewportDefault = 0
; Méthodes prises en charge:
; Delete ()
; GetExtensionDictionary ()
; GetXData (3)
; SetXData (2)
T
transparentes superposables sur un dessin
; Valeurs de propriétés:
; Application (RO) = #<VLA-OBJECT IAcadApplication 00d73d3c>
; Description = ""
; Document (RO) = #<VLA-OBJECT IAcadDocument 01b2cee8>
; Freeze = 0
; Handle (RO) = "4D270"
; HasExtensionDictionary (RO) = -1
; LayerOn = -1
; Linetype = "Continuous"
; Lineweight = 20
; Lock = 0
; Material = "Global"
; Name = "BATIMENT-HACHURES-DES-"
; ObjectID (RO) = 2126729280
; ObjectName (RO) = "AcDbLayerTableRecord"
; OwnerID (RO) = 2126701768
; PlotStyleName = "Color_8"
; Plottable = -1
; TrueColor = #<VLA-OBJECT IAcadAcCmColor 10187240>
; Used (RO) = 0
; ViewportDefault = 0
; Méthodes prises en charge:
; Delete ()
; GetExtensionDictionary ()
; GetXData (3)
; SetXData (2)
T
Lire et écrire des propriété devient un jeu d'enfant :
(setq lLinetype (vla-get-linetype thelayer)) ; pour récupérer le type de ligne du calque
"Continuous"
(vla-put-linetype thelayer "CACHE2") ; pour modifier le type de ligne du calque
nil
Pour info, les propriétés principales des calques :
état : Used
Nom : Name
Actif : LayerOn
Geler : Freeze
Verrouiller : Lock
Couleur : Color
Type de ligne : LineType
Epaisseur de ligne : LineWeight
Style de tracé : PlotStyleName
Tracer : Plottable
Gel dans les nouvelles fenêtres ViewportDefault
Description : Description
Aucun commentaire:
Enregistrer un commentaire