Can't get 'AddTinVolumeSurface method to work.

Can't get 'AddTinVolumeSurface method to work.

tcorey
Mentor Mentor
1,018 Views
7 Replies
Message 1 of 8

Can't get 'AddTinVolumeSurface method to work.

tcorey
Mentor
Mentor

I am at my wits end.

 

Trying to create a Tin Volume Surface using Vlisp.

 

The Surfaces collection has a method called AddTinVolumeSurface (1). The (1) meaning the method takes one arguement, right?

 

Here's the code:

 

 

(setq surfs (vlax-get-property c3ddoc 'Surfaces))              ;sets the Surfaces collection as surfs

 

;(setq surfname (vlax-make-safearray vlax-vbstring '(0 . 0)))   This was an attempt to use a safearray of a single dimension

;(vlax-safearray-fill surfname (list "tempsurface"))   and fill it in with a list.

 

  ;(setq surfname (vlax-make-safearray vlax-vbstring))   Tried it without the dimensions of the array

;(vlax-safearray-fill surfname "TEST"))                   Tried filling the array with a string instead of a string in a list.

  ;(setq surfname "TEST")                                     Tried with the surfname set to a string, not a safearray.

 

  (setq surfname (vlax-make-variant "TEST" vlax-vbstring))        and the most recent try, using a variant.

 

 

(setq surf3 (vlax-invoke-method surfs 'AddTinVolumeSurface surfname))   But when I use this code to create the surface, I get various errors, depending on the option I used creating surfname.

 

What is expected from AddTinVolumeSurface (1). I am putting the surface name in as an arguement, but I can't get it to work. I have tried integers like 0 and 1, I have tried T and F. I really wish there was documentation somewhere that would tell me what is expected here .

 

 

 

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
1,019 Views
7 Replies
Replies (7)
Message 2 of 8

Jeff_M
Consultant
Consultant

@tcorey wrote:

I am at my wits end.

 

What is expected from AddTinVolumeSurface (1). I am putting the surface name in as an arguement, but I can't get it to work. I have tried integers like 0 and 1, I have tried T and F. I really wish there was documentation somewhere that would tell me what is expected here .

  

 


You have to use the COM documentation, Tim. From THIS page you will find you need to pass a TinVolumeCreationData object. Here's some sample code I was playing with a few years ago for a TinSurface. You will need to make appropriate modifications for the TinVolumeSurface and newer versions of C3D. The difference in the TINVolumeCreationData being you also need to set the 2 comparison surfaces.

(vl-load-com)
(setq prod (vlax-product-key))
(setq verstr (cond ((vl-string-search "\\R18.0\\" prod)
		    "7.0"
		   )
		   ;;2010
		   ((vl-string-search "\\R18.1\\" prod)
		    "8.0"
		   )
		   ;;2011
		   ((vl-string-search "\\R18.2\\" prod)
		    "9.0"
		   )
		   ;;2012
	     )
)
(setq prodStr (strcat "AeccXUiLand.AeccApplication." verstr))
(setq datastr (strcat "AeccXLand.AeccTinCreationData." verstr))

(if (and (setq *acad* (vlax-get-acad-object))
	 (setq C3D (vla-getinterfaceobject *acad* prodStr))
	 (setq C3Ddoc (vla-get-activedocument C3D))
	 (setq surfs (vlax-get C3Ddoc 'surfaces))
	 (setq tincreationdata (vla-getinterfaceobject *acad* datastr))
    )
  (progn
    (vlax-put tincreationdata 'baselayer "0")
    (vlax-put tincreationdata 'layer "0")
    (vlax-put tincreationdata 'description "Surface from Lisp")
    (vlax-put tincreationdata 'name "Lisp EG")
    (vlax-put tincreationdata 'style "Border Only")
    ;;style must exist!
    (setq
      surf (vlax-invoke-method surfs 'addtinsurface tincreationdata)
    )
    ;; do whatever else is needed
    (vlax-release-object tincreationdata)
    (vlax-release-object surf)
    (vlax-release-object surfs)
    (vlax-release-object c3ddoc)
  )
)

 And here's the LINK for the general COM help.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 8

tcorey
Mentor
Mentor

Aha. COM documentation. That's gonna be the ticket. I''ve been flying blind and you just removed the blindfold.

 

Thanks, Jeff. Next time I see you I owe you a keg of beer for all your help!

 

Tim

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 4 of 8

tcorey
Mentor
Mentor

 

I am trying to create a TinVolumeSurface and the put-property method is not working for the base surface name;

 

This line works, fills the baselayer property correctly

(vlax-put-property tincreationdata 'BaseLayer "TEMPORARY-FOR-VOLUME-CALCS")

 

This line gives me a type mismatch

     (vlax-put-property tincreationdata 'BaseSurface "Surf1")            

 

I have tried using a string as above, tried pointing to the actual surface object:

 (vlax-put-property tincreationdata 'BaseSurface surf1)

 

Tried pointing to the surface Object id

 (setq surfobjid (vlax-get-property surf1 'ObjectID))

(vlax-put-property tincreationdata 'BaseSurface surfobjid)

 

 As you can see, the tincreationdata object is being created and the BaseLayer property is accepting the put:

 

(vlax-dump-object tincreationdata)
; IAeccTinVolumeCreationData: AeccTinVolumeCreationData interface
; Property values:
;   BaseLayer = "TEMPORARY-FOR-VOLUME-CALCS"
;   BaseSurface = nil
;   ComparisonSurface = nil
;   Description = ""
;   Layer = ""
;   Name = ""
;   Style = ""

 

I can put the description, layer, name and style, too, just not the basesurface and comparison surface.

 

Thanks for any input...

 

Tim

 

 

 

 

 

 

 

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 5 of 8

Jeff_M
Consultant
Consultant

Gah! I knew I should've checked before posting. Sorry Tim, this looks like one of those things that lisp just won't do. It can be done in VBA & .NET, but lisp doesn't pass the correct object type to the tinvolumecreationdata surface properties. 

 

This is the same issue when you try to do this:

(setq surf1 (vlax-invoke-method surfs 'item "Surface1"))

 

It will error with "type mismatch" so you need to loop through the collection to get the surface you want:

(vlax-for surf surfs
      (if (= (vlax-get-property surf 'name) "Surface1")
	(setq surf1 surf)
	(if (= (vlax-get-property surf 'name) "Surface2")
	  (setq surf2 surf)
	  )
	)
      )

 I don't see a backdoor method of passing the correct object type. So it looks like I led you astray on this one, Tim. Sorry about that!

Jeff_M, also a frequent Swamper
EESignature
Message 6 of 8

tcorey
Mentor
Mentor

There's no reason to apologize, Jeff. You have helped so many community members. You're entitled a small mistake once in a while. I only spent an hour or so on it, so no biggie.

 

It looks like I'm just gonna have to knuckle under and learn c#. Peter Funk has stated it here, emphatically, several times, that .net is the way to go. I guess I should listen.

 

Mostly, I'm gonna miss being able to debug on the command line. ;-(

 

Have a great day and thanks for all you do, Jeff.

 

Tim

 

 

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 7 of 8

Anonymous
Not applicable

Hi Tim & Jeff,

 

Sorry to be late on this issue....

Few releases ago I had looked into this and my approach was this :

 

;(vlax-put-property oTinData 'BaseSurface oSurface1)

;(vlax-put-property oTinData 'ComparisonSurface oSurface2)

(setq oVolTinNew (vlax-invoke-method oSurfaces 'AddTinVolumeSurface oTinData))

 

However, I think we had an issue here in using Civil 3D COM / ActiveX API in LISP call. And I had seen some other areas too where it doesn't work and hence I would suggest to move on to use Civil 3D .NET API.

 

Thanks,

Partha

0 Likes
Message 8 of 8

tcorey
Mentor
Mentor

Thanks, Partha. It seems that's the way I'll have to go....



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes