How do I invoke a vlax method in lisp that requires enumerations? Here's my code. It is a port of some VBA code (which works fine), to add custom properties to pipe network parts.
(defun c:PipesExtraProp( / vrs appstr acad aeccApp aeccDoc oSettings oPipeNetworkCatDef param ) (vl-load-com) (setq vrs (vlax-product-key)) (cond ((vl-string-search "R18.1" vrs) (setq appstr "8.0")) ;2011 ((vl-string-search "R18.2" vrs) (setq appstr "9.0")) ;2012 ((vl-string-search "R19.0" vrs) (setq appstr "10.0")) ;2013 ((vl-string-search "R19.1" vrs) (setq appstr "10.3")) ;2014 (t (alert "This command does not support this version of Civil 3D.")) ) (if (and appstr (or acad (setq acad (vlax-get-acad-object) ) ) (or aeccApp (setq aeccApp (vla-getinterfaceobject acad (strcat "AeccXUiPipe.AeccPipeApplication." appstr) ) ) ) (or aeccDoc (setq aeccDoc (vlax-get aeccApp 'ActiveDocument) ) ) ) (progn (setq oSettings (vlax-get aeccDoc 'Settings) ) (setq oPipeNetworkCatDef (vlax-get oSettings 'PipeNetworkCatDef) ) (setq param (vlax-invoke-method oPipeNetworkCatDef 'DeclareNewParameter "TimeOfConcentration" "TimeOfConcentration" "TIME" "TimeOfConcentration" <<aeccDouble>> <<aeccDoubleGeneral>> "" :vlax-true :vlax-false) ) (setq param (vlax-invoke-method oPipeNetworkCatDef 'DeclarePartProperty "TimeOfConcentration" <<aeccDomPipe>> 8.0) ) ) ) (princ) )
I can't figure out how to add the enumerations:
aeccDouble (type AeccPartDataFieldType),
aeccDoubleGeneral (type AeccPipeNetworkUsage),
aeccDomPipe (type AeccPipeNetworkDomain).
Porting the code to .net would obviously be acceptable, but I have been unsuccessful there too. Thanks for any insights.
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
I use Ilspy to read the dll's for the Interops and examine the Types there. It looks like all of these you are interested in are 0 based, increment by 1. Then I use the applicable integer in my lisp.
public enum AeccPartDataFieldType
{
aeccUndefinedDataType,
aeccDouble,
aeccInt,
aeccBool,
aeccString
}
public enum AeccPipeNetworkDomain
{
aeccUndefinedDomain,
aeccDomPipe,
aeccDomStructure,
aeccDomWire
}
public enum AeccPipeNetworkUsage
{
aeccUndefinedUsage,
aeccDoubleGeneral,
aeccDoubleNonZero,
aeccDoubleNonZeroNonNeg,
aeccDoubleDistance,
aeccDoubleDistanceMinor,
aeccDoubleAngle,
aeccDoublePercent,
aeccDoubleArea,
aeccDoubleVolume,
aeccDoubleElevation,
aeccIntGeneral,
aeccIntNonZero,
aeccIntNonZeroNonNeg,
aeccStringGeneral,
aeccStringName,
aeccStringGuid,
aeccStringEnumKey,
aeccBoolGeneral,
aeccMultivalPosition,
aeccMultivalDirection
}
You could also use the (vlax-import-type-library) function, then you can refer to them by name. I used to use this but fell out of the habit quite a while ago.
Simple as that. I had tried integers earlier but couldn't get them to work, so there must have been something else wrong with my code at that time. Works perfect now. Thanks a lot Jeff.