Object does not show when I using my Autolisp copy!

Object does not show when I using my Autolisp copy!

Anonymous
Not applicable
1,118 Views
10 Replies
Message 1 of 11

Object does not show when I using my Autolisp copy!

Anonymous
Not applicable

There is command in Autolisp show the object when I using my lisp copy?
Autolisp seem not to support this one? help me! The attached file is my expecting......

 

-------------------------------

(defun C:Copy (/ dt p1 p2 sl x)
(command "undo" "be")
(setq osm (getvar "osmode"))
(setq dt (ssget)
p1 (getpoint "\nStart point: ")
p2 (acet-ss-drag-move dt p1 "\nPicth: " 1 0)
sl (getint "\nNumber of copy: ")
x 1)
(setvar "osmode" 0)
(repeat sl
(command "copy" dt "" p1 (polar p1 (angle p1 p2) (* (distance p1 p2) x)))
(setq x (1+ x)))
(command "undo" "e")
(setvar "osmode" osm)
(princ))

(vl-load-com)

 

------------------------------------------

0 Likes
1,119 Views
10 Replies
Replies (10)
Message 2 of 11

ВeekeeCZ
Consultant
Consultant

So why you don't use a 'normal' AutoCAD command? How difficult is it to hit 'A' key? 

 

In case that too much - use the following code.

(defun c:CopyArray ( / s n)
  (and (setq s (ssget "_:L"))
       (setq n (getint "\nEnter number of items to array: "))
       (command "_.copy" s "" pause "_A" n pause))
  (princ)
  )

 

0 Likes
Message 3 of 11

Moshe-A
Mentor
Mentor

@Anonymous  hi,

 

There is noting wrong with this lisp command except it's Name (c:copy). when you load this lisp and key-in copy?

AutoCAD will prefere to run his copy version,  sounds logic no?!

 

to solve this change (c:copy) to something else 😀

above that you could use array rectangular (or arraypath) to do the same work.

 

Moshe

 

Message 4 of 11

hak_vz
Advisor
Advisor

Forget

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

So why you don't use a 'normal' AutoCAD command? How difficult is it to hit 'A' key? 

....

....
       (command "_.copy" s "" pause "_A" n pause))
....

The COPY command has not always had the Array option that it has in recent versions, nor has the ARRAY command always had the Path option in recent versions, nor the Angle-of-Array option that the ARRAYCLASSIC dialog box does.  I expect the OP's routine dates from an earlier time before those options.

Kent Cooper, AIA
0 Likes
Message 6 of 11

ВeekeeCZ
Consultant
Consultant

This option was added 10 years ago...

0 Likes
Message 7 of 11

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

This option was added 10 years ago...


Yes, but I certainly still use some custom routines that I wrote further back than that.  If they've been using that all along, maybe they didn't know some of the built-in options now available, and maybe just pointing that out is enough.

Kent Cooper, AIA
Message 8 of 11

Anonymous
Not applicable

Thank you for your reply, but i want to create a new one for my private job, and a want to know is there a lisp to show object when I using autolisp?

0 Likes
Message 9 of 11

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

Thank you for your reply, but i want to create a new one for my private job, and a want to know is there a lisp to show object when I using autolisp?


 

Don't really understand the question.

Yes, you can create new objects with AutoLISP functions. There are several methods to do that.

(command "circle" "non" '(10 10) 2)

(entmake (list (cons 0 "CIRCLE") (cons 10 '(10 10 0)) (cons 40 2))

 

or... using the AddCircle method...

 

(vl-load-com)
(defun c:Example_AddCircle()
    ;; This example creates a circle in model space.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Define the circle
    (setq centerPoint (vlax-3d-point 10 10 0)  
          radius 2)
    
    ;; Create the Circle object in model space
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq circleObj (vla-AddCircle modelSpace centerPoint radius))
    (vla-ZoomAll acadObj)
)

 

... the last one reminds me... what do you mean by 'show'... it's "zoom to"? If yes, use (command "zoom" "o" (entlast) "") or the routine above.

 

0 Likes
Message 10 of 11

hak_vz
Advisor
Advisor

@ВeekeeCZ  If I understand what @Anonymous  want to ask, he maybe asks how to enable object display during command execution (copy or move) i.e whatever involves displaying object(s) while dragging.

This may be related to system variable DRAGMODE.  It has to be set on  2

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 11 of 11

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

There is command in Autolisp show the object when I using my lisp copy?
Autolisp seem not to support this one? help me! The attached file is my expecting......

 

-------------------------------

(defun C:Copy (/ dt p1 p2 sl x)
(command "undo" "be")
(setq osm (getvar "osmode"))
(setq dt (ssget)
p1 (getpoint "\nStart point: ")
p2 (acet-ss-drag-move dt p1 "\nPicth: " 1 0)
sl (getint "\nNumber of copy: ")
x 1)
(setvar "osmode" 0)
(repeat sl
(command "copy" dt "" p1 (polar p1 (angle p1 p2) (* (distance p1 p2) x)))
(setq x (1+ x)))
(command "undo" "e")
(setvar "osmode" osm)
(princ))

(vl-load-com)

 

------------------------------------------


 

You need to have Express Tools installed to make this command work. Apart from the name collision the routine work fine for me (ACAD 2020). Also, it seems that it could have some issues with ORTHO but I can't confirm that.

0 Likes