PDA

View Full Version : How to know if sketch excists?


Harry
03-16-2005, 05:10 AM
I like to delete a sketch if it excists. I made to code below.


(defun my-lisp-function (......)
.......
;get current sheet
(setf current_sheet (docu::docu-inq-current-sheet-name))
(setf sketch_name (format nil "~A/Docu_bom_sketch" current_sheet) )

(when (sd-pathname-to-obj sketch_name)
(am_sketch_delete :sketch sketch_name :YES)
)
.......
);defun


But line when() always gives a nil back. When I enter the next line in the command prompt, the sketch will be deleted.
(am_sketch_delete :sketch sketch_name :YES)

When I replaced the code with the lines below, the same result.


(when (sd-pathname-to-obj "1/Docu_bom_sketch")
(am_sketch_delete :sketch "1/Docu_bom_sketch" :YES)
)


Is it possible at all to check if a sketch excists before removng it?

Best regards,

Harry

Wolfgang
03-16-2005, 10:52 AM
sd-pathname-to-obj is not supported for 'ME10 parts' inside of annotation // for Annotation objects.

The way you inquire the current sheet name is not supported, too.

Well, the (setf...) construction you are using is supported :D ;) .


Supported is : sd-am-inq-all-sketches, sd-am-inq-curr-sheet-name, sd-am-inq-curr-sheet

pseudo code (just out of my mind, not tested, never executed)

(dolist (a-sketch (sd-am-inq-all-sketches (sd-am-inq-curr-sheet)))
(when (sd-string= (SD-AM-INQ-NAME a-sketch) the-name)
(sd-call-cmds (am_sketch_delete :sketch a-sketch :YES))
)
)HTH

Harry
03-18-2005, 05:46 AM
Thanks Wolfgang,

Finally, I changed my code in this:

;get current sheet
(setf current_sheet (docu::docu-inq-current-sheet-name))
(setf sketch_name (format nil "~A/Docu_bom_sketch" current_sheet) )

(dolist (a_sketch (SD-AM-INQ-ALL-SKETCHES (SD-AM-INQ-CURR-SHEET)))
(setf found_sketch (format nil "~A/~A" current_sheet (SD-AM-INQ-NAME a_sketch)) )
(when (sd-string= found_sketch sketch_name)
(SD-CALL-CMDS (am_sketch_delete :sketch found_sketch :YES))
(print (format nil "sketch '~A' removed" found_sketch))
);when
);dolist



I think I am going to like osdm and lisp... :)

Harry

Wolfgang
03-20-2005, 01:16 PM
Hi Harry,

you can do the check for "correct" sketch name also without the current sheet, because a) you only want to do it on the current sheet, b) you only inquire the sketches of the current sheet.


(setf sketch_name "Docu_bom_sketch")

(dolist (a_sketch (SD-AM-INQ-ALL-SKETCHES (SD-AM-INQ-CURR-SHEET)))
(setf found_sketch (SD-AM-INQ-NAME a_sketch)))
(when (sd-string= found_sketch sketch_name)
(SD-CALL-CMDS (am_sketch_delete :sketch a_sketch :YES))
(print (format nil "sketch '~A' removed from current sheet" found_sketch))
);when
);dolist


Hmmm.. I'm in doubt about other sketches.. Let's assume:
sheet 1
+-----sketch Docu_bom_sketch
+-----view front 1
+-----view left 7
+----------sketch Docu_bom_sketch
+-----Frame A3
+----------Title Block
+----------------sketch Docu_bom_sketch

I'm not sure whether 'My' loop would delete all matching sketches.

Harry
03-21-2005, 11:06 PM
I know what you mean Wolfgang. If you want to do it 'correct' (as a generic solution) you have to check every level below every view which are in the current sketch.
But I know that I am looking for a sketch named '<sheetnumber>/Docu_bom_sketch'.

You are right about teh fact that I can remove the sheetnumber during name checking. Like you said, I am only looking below this one and only sheet.

Best regards,

Harry