Message 1 of 8
Open document and connect to active document - what's difference?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have to process some files. I write code which opens file, process it, closes, opens next file and so on. And - this code do not work.
Code:
; Select rectangle region and delete all inside it:
(defun DelRegion ( doc rect / ssetObj modItem )
; Create the selection set:
(setq ssetObj (vla-Add (vla-get-SelectionSets doc) "FRAME"))
; select objects to delete:
(vla-SelectByPolygon ssetObj acSelectionSetCrossingPolygon rect)
; delete them.
(vlax-for modItem ssetObj
(vla-Delete modItem)
)
(vla-Delete ssetObj) ; Delete the selection set.
)
; select filename and launch file proceed procedure:
(defun C:batchprocrunner ( / acadObj doc )
(setq acadObj (vlax-get-acad-object))
; 1 option: open file:
(setq doc (vla-Open (vla-get-Documents acadObj) "file.dwg"))
; 2 option: connect to opened file:
(setq doc (vla-get-Activedocument acadObj))
; Run the function:
(DelRegion doc FSAArray1)
)
The problem is: my code works well if I comment out 1 option and choose 2 one (manually open file, activate it and get link to active document).
If I do vice-versa (comment out 2 option and try to open document) - code do not work.
What can I do with it?