Zykl0 Posted June 5, 2009 Posted June 5, 2009 Hello, i'm verry noob with lisp and i have a simple question. i know its easy to call a lisp function inside acad when they include something like defun: but how do i call a function when the structure is like this Option Explicit Public Sub Main() code here code here code here code here code here code here code here code here code here End Sub Quote
Freerefill Posted June 5, 2009 Posted June 5, 2009 Calling functions is pretty much the same no matter what, the only difference I've really come across is whether it's a command or a function. The only difference is whether or not it's preceeded by a c:, like so: ; Command (defun c:dothis() (princ "hello world") ) ; Function (defun dothisalso() (princ "What's up?") ) I hope that answers your question, if not, I could try again ^^' Quote
Zykl0 Posted June 5, 2009 Author Posted June 5, 2009 Im not sure how do i call this code inside autoCAD ... do i need to add a function inside the code? Option Explicit Public Sub Main() Dim objBlock As AcadBlockReference Dim objEnt As AcadEntity Dim colHyps As AcadHyperlinks Dim fso As FileSystemObject Set fso = New FileSystemObject For Each objEnt In ThisDrawing.ModelSpace If TypeOf objEnt Is AcadBlockReference Then Set objBlock = objEnt Set colHyps = objBlock.Hyperlinks On Error Resume Next ' In case we encounter any blocks that DON'T have hyperlinks fso.CopyFile colHyps.Item(0).URL, "E:\Temp\" ' replace E:\Temp\ with your project directory End If Next objEnt Set fso = Nothing End Sub Quote
Commandobill Posted June 5, 2009 Posted June 5, 2009 Calling functions is pretty much the same no matter what, the only difference I've really come across is whether it's a command or a function. The only difference is whether or not it's preceeded by a c:, like so: ; Command (defun c:dothis() (princ "hello world") ) ; Function (defun dothisalso() (princ "What's up?") ) I hope that answers your question, if not, I could try again ^^' what he appears to be asking is how to call a vba routine inside cad. and im quite new to vba and the only way i personally know how to run those is through 'vbaide' or 'vbarun' Quote
Zykl0 Posted June 8, 2009 Author Posted June 8, 2009 Not working i tried (defun c:dothis() Option Explicit Public Sub Main() Dim objBlock As AcadBlockReference Dim objEnt As AcadEntity Dim colHyps As AcadHyperlinks Dim fso As FileSystemObject Set fso = New FileSystemObject For Each objEnt In ThisDrawing.ModelSpace If TypeOf objEnt Is AcadBlockReference Then Set objBlock = objEnt Set colHyps = objBlock.Hyperlinks On Error Resume Next ' In case we encounter any blocks that DON'T have hyperlinks fso.CopyFile colHyps.Item(0).URL, "E:\Temp\" ' replace E:\Temp\ with your project directory End If Next objEnt Set fso = Nothing End Sub ) and (defun c:dothis() Dim objBlock As AcadBlockReference Dim objEnt As AcadEntity Dim colHyps As AcadHyperlinks Dim fso As FileSystemObject Set fso = New FileSystemObject For Each objEnt In ThisDrawing.ModelSpace If TypeOf objEnt Is AcadBlockReference Then Set objBlock = objEnt Set colHyps = objBlock.Hyperlinks On Error Resume Next ' In case we encounter any blocks that DON'T have hyperlinks fso.CopyFile colHyps.Item(0).URL, "E:\Temp\" ' replace E:\Temp\ with your project directory End If Next objEnt Set fso = Nothing End Sub ) any other idea? Quote
Lee Mac Posted June 8, 2009 Posted June 8, 2009 You are mixing up LISP with VBA - two very different things Quote
Zykl0 Posted June 8, 2009 Author Posted June 8, 2009 how do i call this function... this is only what i want to know PLEASE Quote
Commandobill Posted June 8, 2009 Posted June 8, 2009 you should have that file saved as a .dvb so you can make a lisp that looks like this [color=Black][color=#383838](defun c:LoadMacro () (setvar "filedia" 0);//To avoid the VBALOAD dialog box display (command "_VBALOAD" "c:\\temp\\macro.dvb");<--- change to your vba file (setvar "filedia" 1);//Reset filedia to 1 (command "_-VBARUN" "macro1");//- To avoid the VBARUN dialog box display )[/color][/color] reference : http://usa.autodesk.com/adsk/servlet/ps/item?siteID=123112&id=2888989&linkID=9240617 Quote
Lee Mac Posted June 8, 2009 Posted June 8, 2009 This may help also: http://www.cadtutor.net/forum/showthread.php?t=34207 Quote
Commandobill Posted June 8, 2009 Posted June 8, 2009 This may help also: http://www.cadtutor.net/forum/showthread.php?t=34207 I should've assumed there was a vl solution Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.