AutoCAD Civil 3D Customization

AutoCAD Civil 3D Customization

Reply
Mentor
192 Posts
26 Kudos
Registered: ‎08-17-2007
Post 1 of 3
Accepted Solution

vlax-invoke-method enumeration question (Custom Part Properties)

258 Views, 2 Replies
02-24-2014 02:56 PM

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.

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.

*Expert Elite*
4,621 Posts
921 Kudos
Registered: ‎07-22-2003
Post 2 of 3

Re: vlax-invoke-method enumeration question (Custom Part Properties)

02-24-2014 04:51 PM in reply to: tyronebk

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.

Jeff_M, also a frequent Swamper
Mentor
192 Posts
26 Kudos
Registered: ‎08-17-2007
Post 3 of 3

Re: vlax-invoke-method enumeration question (Custom Part Properties)

02-25-2014 08:55 AM in reply to: Jeff_M

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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!