Lesson 3 -- Drawing the Path Boundary Drawing AutoCAD Entities Most AutoLISP programs draw entities using one of several methods: ActiveX functions The entmake function The command function Can anybody give me sample,how to draw entities by "ActiveX" function,second and third function I've known it,thanks for your reply. Best regards Ade Suharna
This will place a new line in the current drawing's modelspace on the current layer: (setq pt1 (getpoint "\nSelect line start point: ") pt2 (getpoint pt1 "\nSelect line end point: ")) (setq newline (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) "addLine" pt1 pt2 )) Good luck! Jeff
Hi Jeff,What wrong ?? (setq pt1 (getpoint "\nSelect line start point: ") pt2 (getpoint pt1 "\nSelect line end point: ")) (setq newline (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) "addLine" pt1 pt2 )) (18.7673 12.5217 0.0) ; error: no function definition: VLAX-GET-ACAD-OBJECT ;>>>> ????
Help to fill in,thanks (setq pt1 (getpoint "\nSelect line start point: ") pt2 (getpoint pt1 "\nSelect line end point: ")) (setq newline (vlax-invoke ; >>>>>> call the specified ActiveX method (vla-get-modelspace ; >>>>>> ????? (vla-get-activedocument ; >>>>>> ????? (vlax-get-acad-object ; >>>>>> Retrieves the top level AutoCAD ; >>>>>> application object for the current ; >>>>>> AutoCAD session ))) "addLine" : >>>>>> ????? pt1 pt2 ))
First, I should have mentioned that (vl-load-com) needs to be run once in a drawing before the activex commands can be run. That should eliminate the error you got. See below To break it down further, you could do this: (setq acad (vlax-get-acad-object)) (setq doc (vla-get-activedocument acad));;This could also be written as (vlax-get-property acad 'activedocument) (setq mspace (vla-get-modelspace doc));; OR (vlax-get-property doc 'modelspace) (setq newline (vlax-invoke mspace "addline" pt1 pt2));; this could also be written using (vla-addline), but then the pt1 & pt2 lists would need to be converted to vlax-variants which is a whole 'nother "can of worms". Hope that helps, Jeff