How to force running commands in the created drawing ?

How to force running commands in the created drawing ?

y.awwad
Contributor Contributor
475 Views
7 Replies
Message 1 of 8

How to force running commands in the created drawing ?

y.awwad
Contributor
Contributor

How to force running commands in the created drawing ?

 

I created a new drawing using ( vla-add )

The code creates a point in the created drawing but ( zoom extents ) in the original drawing not the created drawing  .. anyone can help in this ?

 

(defun C:DRZ (/ acadApp acadDoc)

  (vl-load-com)
  (setq acadApp (vlax-get-acad-object))
  (setq acadDoc (vla-Add (vla-get-Documents acadApp)))
  (vla-AddPoint (vla-get-ModelSpace acadDoc) (vlax-3d-point 10000 10000 0))
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (vla-put-ActiveDocument acadApp acadDoc)
  (vla-ZoomExtents acadApp)
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (vla-Activate acadDoc)
  (vla-SendCommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "Zoom" " " "e" " "))
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (princ)

)
(princ)
0 Likes
476 Views
7 Replies
Replies (7)
Message 2 of 8

ec-cad
Collaborator
Collaborator
; Try changing:
(vla-SendCommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "Zoom" " " "e" " "))
; To be:
(vla-SendCommand acadDoc (strcat "Zoom" " " "e" " "))

ECCAD

0 Likes
Message 3 of 8

y.awwad
Contributor
Contributor

@ec-cad

 

Same issue .. The code created a point in the created drawing but ( zoom extents ) in the original drawing not the created drawing

0 Likes
Message 4 of 8

komondormrex
Mentor
Mentor

@y.awwad 

try this one. you cannot zoom extents a point if pdmode is set to 0.

(defun C:DRZ (/ acadApp acadDoc)
  (vl-load-com)
  (setq acadApp (vlax-get-acad-object))
  (setq acadDoc (vla-Add (vla-get-Documents acadApp)))
  (vla-put-ActiveDocument acadApp acadDoc)
  (vla-postcommand acadDoc "pdmode 3 ")
  (vla-postcommand acadDoc "point 10000,10000,0 ")
  (vla-postCommand acadDoc "Zoom e ")
  (princ)
)

 

Message 5 of 8

y.awwad
Contributor
Contributor

@komondormrex 

Thanks for replying , I tried the code .. it keeps loading till i select the original drawing and click anywhere ( when i return back to created drawing i found it zoomed extents ) but i have to select the original drawing and left click anywhere 1st to stop hanging , Do you have a solution for this ?

0 Likes
Message 6 of 8

ВeekeeCZ
Consultant
Consultant

Last time I was fighting the same issue ended up with using acaddoc.lsp. 

 

https://forums.autodesk.com/t5/civil-3d-customization/vla-sendcommand-issue/m-p/12251272#M24275

 

0 Likes
Message 7 of 8

y.awwad
Contributor
Contributor

@ВeekeeCZ 

 

Strange that Autodesk didn't put an option to do so 🤦‍

0 Likes
Message 8 of 8

komondormrex
Mentor
Mentor

triple <Esc>.

but you should to look at odbx.

0 Likes