Hello. I know that most people will just tell me to switch to .NET for this, but I'm going to first counter with "Until I'm absolutely out of interpreter based options will I switch to a compiled language"
Background: I have been working to get similar functionality of an existing LISP suite of applications for LDD into comparable C3D versions. Largely these are things to double check math that some people signing documents would rather have a secondary answer than just the Autodesk C3D black box number (Not willing to be sued because Autodesk said the number was right), and adding back-up functionality for c3d objects that in LDD would be stored off in an external database.
Problem: Currently, I'm just trying to rewrite one of the sample VBA applications for experience/learning. So here is the code so far..
(setq oApp (vlax-get-acad-object))
(setq g_oCivilApp (vlax-invoke-method oApp 'GetInterfaceObject "AeccXUiLand.AeccApplication.8.0"))
(setq g_oDocument (vlax-get-property g_oCivilApp 'ActiveDocument))
(setq g_oAeccDatabase (vlax-get-property g_oDocument 'Database))
(setq oSurfaces (vlax-get-property g_oDocument "Surfaces"))
It works up to this point. I end up with a #<vla-object IAeccSurfaces> as expected.
But the next part is where it gets strange. I'm checking to see if the surface I want is already in the drawing.. According to the COM documentation, there is a Item() method for AeccSurfaces. If I call
(setq oSurface (vlax-invoke-method oSurfaces "Item" SURFACE_NAME))
like what I would assume be the way to go by all the documentation... it returns
; error: ActiveX Server returned an error: Type mismatch
so I tried the undocumented vlax-invoke that I've seen in the forums while looking up this problem.
(setq oSurface (vlax-invoke oSurfaces "Item" SURFACE_NAME))
; error: Member not found
Alright. So this doesn't make any sense, the documentation states that there is a method called item.. so I test something
(vlax-dump-object oSurfaces 1)
; IAeccSurfaces: IAeccSurfaces interface
; Property values:
; Count (RO) = 1
; Item (RO) = ...Indexed contents not shown...
; Methods supported:
; AddGridSurface (1)
; AddGridVolumeSurface (1)
; AddTinSurface (1)
; AddTinVolumeSurface (1)
; ImportDEM (1)
; ImportTIN (1)
; ImportXML (1)
; Remove (1)
So this states that Item() is a property! This should help me right? So I try
(setq oSurface (vlax-get-property oSurfaces "Item" SURFACE_NAME))
; error: Automation Error. Description was not provided.
hmm, undocumented get?
(setq oSurface (vlax-get oSurfaces "item" SURFACE_NAME))
; error: too many arguments
Try it without giving it the argument...
(setq oSurface (vlax-get oSurfaces "item"))
; error: Invalid number of parameters
So... I'm flabberghasted. Documentation says one thing, actual object says another, and nothing works!
Is there a way to fix this mixup in the way the object has been set up? I'm using Civil3d 2011.
Solved! Go to Solution.
Hello. I know that most people will just tell me to switch to .NET for this, but I'm going to first counter with "Until I'm absolutely out of interpreter based options will I switch to a compiled language"
Background: I have been working to get similar functionality of an existing LISP suite of applications for LDD into comparable C3D versions. Largely these are things to double check math that some people signing documents would rather have a secondary answer than just the Autodesk C3D black box number (Not willing to be sued because Autodesk said the number was right), and adding back-up functionality for c3d objects that in LDD would be stored off in an external database.
Problem: Currently, I'm just trying to rewrite one of the sample VBA applications for experience/learning. So here is the code so far..
(setq oApp (vlax-get-acad-object))
(setq g_oCivilApp (vlax-invoke-method oApp 'GetInterfaceObject "AeccXUiLand.AeccApplication.8.0"))
(setq g_oDocument (vlax-get-property g_oCivilApp 'ActiveDocument))
(setq g_oAeccDatabase (vlax-get-property g_oDocument 'Database))
(setq oSurfaces (vlax-get-property g_oDocument "Surfaces"))
It works up to this point. I end up with a #<vla-object IAeccSurfaces> as expected.
But the next part is where it gets strange. I'm checking to see if the surface I want is already in the drawing.. According to the COM documentation, there is a Item() method for AeccSurfaces. If I call
(setq oSurface (vlax-invoke-method oSurfaces "Item" SURFACE_NAME))
like what I would assume be the way to go by all the documentation... it returns
; error: ActiveX Server returned an error: Type mismatch
so I tried the undocumented vlax-invoke that I've seen in the forums while looking up this problem.
(setq oSurface (vlax-invoke oSurfaces "Item" SURFACE_NAME))
; error: Member not found
Alright. So this doesn't make any sense, the documentation states that there is a method called item.. so I test something
(vlax-dump-object oSurfaces 1)
; IAeccSurfaces: IAeccSurfaces interface
; Property values:
; Count (RO) = 1
; Item (RO) = ...Indexed contents not shown...
; Methods supported:
; AddGridSurface (1)
; AddGridVolumeSurface (1)
; AddTinSurface (1)
; AddTinVolumeSurface (1)
; ImportDEM (1)
; ImportTIN (1)
; ImportXML (1)
; Remove (1)
So this states that Item() is a property! This should help me right? So I try
(setq oSurface (vlax-get-property oSurfaces "Item" SURFACE_NAME))
; error: Automation Error. Description was not provided.
hmm, undocumented get?
(setq oSurface (vlax-get oSurfaces "item" SURFACE_NAME))
; error: too many arguments
Try it without giving it the argument...
(setq oSurface (vlax-get oSurfaces "item"))
; error: Invalid number of parameters
So... I'm flabberghasted. Documentation says one thing, actual object says another, and nothing works!
Is there a way to fix this mixup in the way the object has been set up? I'm using Civil3d 2011.
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
Thank you Jeff. Not only have you solved my problem (without repeating yourself, always a plus), but you've also given light that I was searching the forum incorrectly! I'll try not to post about problems already solved in the future.
Thanks again
Thank you Jeff. Not only have you solved my problem (without repeating yourself, always a plus), but you've also given light that I was searching the forum incorrectly! I'll try not to post about problems already solved in the future.
Thanks again
Feel free to ask about most anything, although if you include "lisp" anywhere in your post be prepared for less than a handful of us responding. When I can remember posting something previously I'll usually try to link back to it, not to try to get you to look for it, but because there is quite often other useful information in the older thread. When I posted that yesterday, I wanted to be a bit more verbose, but I was in a hurry and thought you may be able to use the information before I was able to make a more detailed posting. So I'm glad it worked for you. 🙂
Feel free to ask about most anything, although if you include "lisp" anywhere in your post be prepared for less than a handful of us responding. When I can remember posting something previously I'll usually try to link back to it, not to try to get you to look for it, but because there is quite often other useful information in the older thread. When I posted that yesterday, I wanted to be a bit more verbose, but I was in a hurry and thought you may be able to use the information before I was able to make a more detailed posting. So I'm glad it worked for you. 🙂
I'm greatful. What I kind of meant about the searching the forums thing was that I was looking for my errors and such, and not searching for the actual solution I was going towards.
This little project is making me see where parts would be easier in a standard procedural language rather than a functional one. Almost every one of the larger program bits are a giant 'cond statement. I've just been avoiding the compiled languages personally for a couple reasons. Its a bit harder to test little bits out at a time having to finish far enough to get a compile done, and I completely failed to get something working right in ObjectARX back in 2005 so the whole compiled thing left a bad taste. At work though, I have other reasons, mostly being compatibility with existing libraries and the amount of work it takes to get things working between versions. I just installed 2011 on my machine, and so far, most every routine works exactly how it worked in 2008.. and 2005.. and 2002.. and r14... at least for the Vanilla AutoCAD routines... no recompiling per version (or 3 versions). Kind of just sad to see such a powerful tool (sometimes slow though) be abandoned.
I'm greatful. What I kind of meant about the searching the forums thing was that I was looking for my errors and such, and not searching for the actual solution I was going towards.
This little project is making me see where parts would be easier in a standard procedural language rather than a functional one. Almost every one of the larger program bits are a giant 'cond statement. I've just been avoiding the compiled languages personally for a couple reasons. Its a bit harder to test little bits out at a time having to finish far enough to get a compile done, and I completely failed to get something working right in ObjectARX back in 2005 so the whole compiled thing left a bad taste. At work though, I have other reasons, mostly being compatibility with existing libraries and the amount of work it takes to get things working between versions. I just installed 2011 on my machine, and so far, most every routine works exactly how it worked in 2008.. and 2005.. and 2002.. and r14... at least for the Vanilla AutoCAD routines... no recompiling per version (or 3 versions). Kind of just sad to see such a powerful tool (sometimes slow though) be abandoned.
Dear Jeff,
The red color code line getting an error. any solution to change the Surface style through Lisp.
Thanks in advance.
Saif
(defun c:Srsty (/ ss1 N i ent2 ent3 Stnm)
(setq ss1 (ssget "X" '((0 . "AECC_TIN_SURFACE")) ) )
(setq N (sslength ss1) )
(setq i 0)
(setq Stnm (getstring T "\nType Surface Style Name:"))
(Repeat N
(setq ent2 (ssname ss1 i))
(setq ent3 (vlax-ename->vla-object ent2) )
(vla-put-stylename ent3 Stnm )
(setq i (+ i 1))
)Repeat close
(princ)
)
Dear Jeff,
The red color code line getting an error. any solution to change the Surface style through Lisp.
Thanks in advance.
Saif
(defun c:Srsty (/ ss1 N i ent2 ent3 Stnm)
(setq ss1 (ssget "X" '((0 . "AECC_TIN_SURFACE")) ) )
(setq N (sslength ss1) )
(setq i 0)
(setq Stnm (getstring T "\nType Surface Style Name:"))
(Repeat N
(setq ent2 (ssname ss1 i))
(setq ent3 (vlax-ename->vla-object ent2) )
(vla-put-stylename ent3 Stnm )
(setq i (+ i 1))
)Repeat close
(princ)
)
Can't find what you're looking for? Ask the community or share your knowledge.