Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting Field values via AutoLISP

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
dennis
1431 Views, 6 Replies

Setting Field values via AutoLISP

I have dug and dug and getting lost.  So, asking instead of beating my head on the wall.

This is particularly for Plant3D, but it has to do with Fields.  I want to "read" the file name and extract out a section of the dwgname to assign to the field CurrentDwgArea, whose expression is %<\PnID DrawingProperties.General.Area>%.

Extracting out the value from the dwgname that I want is no problem, but assigning it then to the CurrentDwgArea field is where I am perplexed.

If it is needed, in the Field dialog, the Field Catagory is Project (and how does that relate to the expression, I have no clue).

 

So how do you assign a value to a Field via AutoLISP?  Any help would be appreciated.

6 REPLIES 6
Message 2 of 7
GTVic
in reply to: dennis

I think generally fields are used to retrieve values, they cannot be assigned.

 

Have a look at this thread for more info/ideas:

http://forums.autodesk.com/t5/AutoCAD-2004-2005-2006/Field-Lisp-Value/td-p/1420933

Message 3 of 7
dennis
in reply to: GTVic

I mentioned that this was specific to Plant 3D where you can create custom fields via the Project Manager and then assign values to those fields either in the PM or through the Properties of the specific DWGs within the PM.  An aggrivation with the PM Setup is not being able to assign fields to the FIle Name Format leaving you with the situation where you have to enter the AREA of the Plant design twice.  That is what I was in hopes of overcoming with the lisp.

I am still thinking, "there's gotta be a way"

Message 4 of 7
GTVic
in reply to: dennis

In vanilla AutoCAD you can also create custom properties using DWGPROPS. 

 

The dialog stores the property and the field is used to retrieve it, so field is retrieve only.

 

However, if the property is accessible then it can be modified from LISP as shown in this example:

 

http://adndevblog.typepad.com/autocad/2012/12/visual-lisp-example-for-controlling-drawing-properties...

Message 5 of 7
dennis
in reply to: GTVic

Hey GTVic, I think you are getting me close.  But, this FIELD is not the SummaryInfo.  It is more like a custom field in a catagory called Project.  See my attached word doc to help you see better what I am after.  This is particular to Plant 3D.  You have given me a little bit of hope that this can be done.

 

Message 6 of 7
GTVic
in reply to: dennis

The best that you can do is maybe install the VBA component for Plant 3D. Start VBA with VBAIDE, hit F2 to bring up the object browser and try to search for this property. Or do a similar search using LISP as shown here.

 

This example shows getting the document object and dumping all available properties of document. Notice that SummaryInfo is a property containing another object. Doing this in Plant 3D may show other objects e.g. PlantProperties. The next command shows the technique to dump all the properties of SummaryInfo. Again, in Plant 3D, SummaryInfo may contain more properties. Or start at a higher level, e.g. (vlax-dump-object (vlax-get-acad-object)).

 

Command: (vl-load-com)
Command: (setq acadDocument (vla-get-ActiveDocument (vlax-get-acad-object)))

#<VLA-OBJECT IAcadDocument 000000002a9827f8>

Command: (vlax-dump-object acaddocument)

; IAcadDocument: An AutoCAD drawing
; Property values:
;   Active (RO) = -1
;   ActiveDimStyle = #<VLA-OBJECT IAcadDimStyle 00000000307e5828>
;   ActiveLayer = #<VLA-OBJECT IAcadLayer 00000000307e7568>
;   ActiveLayout = #<VLA-OBJECT IAcadLayout 00000000304d2b38>
;   ActiveLinetype = #<VLA-OBJECT IAcadLineType 00000000304d21a8>
;   ActiveMaterial = #<VLA-OBJECT IAcadMaterial 00000000304d27d8>
;   ActivePViewport = AutoCAD: No active viewport in paperspace
;   ActiveSelectionSet (RO) = #<VLA-OBJECT IAcadSelectionSet 0000000030d01638>
;   ActiveSpace = 1
;   ActiveTextStyle = #<VLA-OBJECT IAcadTextStyle 00000000307e5708>
;   ActiveUCS = AutoCAD: Null object ID
;   ActiveViewport = #<VLA-OBJECT IAcadViewport 00000000304d2088>
;   Application (RO) = #<VLA-OBJECT IAcadApplication 000000013fc03318>
;   Blocks (RO) = #<VLA-OBJECT IAcadBlocks 00000000304d26b8>
;   Database (RO) = #<VLA-OBJECT IAcadDatabase 0000000030d01698>
;   Dictionaries (RO) = #<VLA-OBJECT IAcadDictionaries 00000000304d2598>
;   DimStyles (RO) = #<VLA-OBJECT IAcadDimStyles 00000000304d2f28>
;   ElevationModelSpace = 0.0
;   ElevationPaperSpace = 0.0
;   FileDependencies (RO) = #<VLA-OBJECT IAcadFileDependencies 0000000030cd0f38>
;   FullName (RO) = ""
;   Groups (RO) = #<VLA-OBJECT IAcadGroups 00000000304d2748>
;   Height = 1028
;   HWND (RO) = 67300
;   HWND32 (RO) = 67300
;   Layers (RO) = #<VLA-OBJECT IAcadLayers 00000000304d2628>
;   Layouts (RO) = #<VLA-OBJECT IAcadLayouts 00000000304d1ff8>
;   Limits = (-40.0 -25.0 825.0 584.0)
;   Linetypes (RO) = #<VLA-OBJECT IAcadLineTypes 00000000304d3168>
;   Materials (RO) = #<VLA-OBJECT IAcadMaterials 00000000304d30d8>
;   ModelSpace (RO) = #<VLA-OBJECT IAcadModelSpace 0000000030b54748>
;   MSpace = AutoCAD: Invalid mode
;   Name (RO) = "Drawing1.dwg"
;   ObjectSnapMode = 0
;   PaperSpace (RO) = #<VLA-OBJECT IAcadPaperSpace 0000000030b54b08>
;   Path (RO) = "C:\\Data"
;   PickfirstSelectionSet (RO) = #<VLA-OBJECT IAcadSelectionSet 0000000030d017b8>
;   Plot (RO) = #<VLA-OBJECT IAcadPlot 0000000030cd1708>
;   PlotConfigurations (RO) = #<VLA-OBJECT IAcadPlotConfigurations 00000000304d2fb8>
;   Preferences (RO) = #<VLA-OBJECT IAcadDatabasePreferences 0000000030cd08f8>
;   ReadOnly (RO) = 0
;   RegisteredApplications (RO) = #<VLA-OBJECT IAcadRegisteredApplications 00000000304d33a8>
;   Saved (RO) = 0
;   SectionManager (RO) = Exception occurred
;   SelectionSets (RO) = #<VLA-OBJECT IAcadSelectionSets 000000003049a5f8>
;   SummaryInfo (RO) = #<VLA-OBJECT IAcadSummaryInfo 0000000030ba6b08>
;   TextStyles (RO) = #<VLA-OBJECT IAcadTextStyles 00000000304d3438>
;   UserCoordinateSystems (RO) = #<VLA-OBJECT IAcadUCSs 00000000304d3048>
;   Utility (RO) = #<VLA-OBJECT IAcadUtility 0000000030cd1838>
;   Viewports (RO) = #<VLA-OBJECT IAcadViewports 00000000304d34c8>
;   Views (RO) = #<VLA-OBJECT IAcadViews 00000000304d3288>
;   Width = 1566
;   WindowState = 3
;   WindowTitle (RO) = "Drawing1.dwg"
T

Command: (setq dProps (vlax-get-Property acadDocument 'SummaryInfo))

#<VLA-OBJECT IAcadSummaryInfo 0000000030ba6b08>

Command: (vlax-dump-object dprops)
; IAcadSummaryInfo: IAcadSummaryInfo Interface
; Property values:
;   Author = ""
;   Comments = ""
;   HyperlinkBase = ""
;   Keywords = ""
;   LastSavedBy = "joe_user"
;   RevisionNumber = ""
;   Subject = ""
;   Title = ""
T

 

Message 7 of 7
dennis
in reply to: GTVic

Well, the definitive answer for what I wanted to do has come from the Customer & Expert Council for P&ID and Plant3D.  Pretty much with customizing Plant 3D it needs to be done with .NET or C++ in that the LISP APIs have not been developed.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost