Author Topic: Please break my routine......  (Read 10420 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Please break my routine......
« Reply #15 on: March 26, 2014, 08:03:12 PM »
Ok, that works; however, I had a situation where I was in the middle of testing it and needed to use the clipboard for something else, so I am trying to avoid using the clipboard.

I have updated the first post with 3.0F, but it seems to set one of the points to 0,0 for some reason when it kicks in, otherwise it works ok. Any ideas?

ribarm

  • Gator
  • Posts: 3300
  • Marko Ribar, architect
Re: Please break my routine......
« Reply #16 on: March 27, 2014, 04:19:33 AM »
I don't know what is it - it's bug in (VL Mleader) object... I thought that safearray was wrong - you've written '(1 . 6) and in some examples on www I found '(0 . 5), but that didn't fix it... Here is my portion of your mods :

Code: [Select]
(cond
((and (= *Content* "MTEXT") (= *POC* nil))
(if (/= (vla-get-ContentBlockName mlobj) "")
(progn
(if (null newpoints3) (setq newpoints3 (vla-GetLeaderLineVertices mlobj 0)))
(if (and (/= mlobj nil) (not (vlax-erased-p mlobj)))
(progn
(vla-delete mlobj)
(vlax-release-object mlobj)
)
)
(if (or (/= (getvar "cvport") 1) (/= (getvar "tilemode") 0))
(progn
                                                                                                (setq np3 (vlax-make-safearray vlax-vbDouble '(0 . 5)))
                                                                                                (setq np3 (vlax-safearray-fill np3 (vlax-safearray->list (vlax-variant-value newpoints3))))
(setq mlobj (vla-AddMleader *modelspace* np3 0))
                                                                                                (vla-update mlobj)
(vla-SetLeaderLineVertices mlobj 0 np3)
)
(progn
                                                                                                (setq np3 (vlax-make-safearray vlax-vbDouble '(0 . 5)))
                                                                                                (setq np3 (vlax-safearray-fill np3 (vlax-safearray->list (vlax-variant-value newpoints3))))
(setq mlobj (vla-AddMleader *paperspace* np3 0))
                                                                                                (vla-update mlobj)
(vla-SetLeaderLineVertices mlobj 0 np3)
)
)
(vla-put-StyleName mlobj (GETVAR "CMLEADERSTYLE"))
(setq TstObj mlobj)
)
)
(if (or (= *TEXT* "") (= *TEXT* nil))
(vla-put-TextString mlobj "BREEN\\PENGINEERING")
(vla-put-TextString mlobj *TEXT*)
)
(if (> (car pt1) (car FxPt))
(vla-put-TextJustify mlobj acAttachmentPointTopRight)
)
); End of condition

I've also noticed that in my version 3.0e when changing arrowstyle and pointstyle more times, sometimes leader slightly makes displacement at text insert point, so I've included this line :

Code: [Select]
(if (null lstpt) (setq lstpt (vla-GetLeaderLineVertices mlobj 0)))

instead of just :
Code: [Select]
(setq lstpt (vla-GetLeaderLineVertices mlobj 0))

This change will make sure first LeaderLineVertices are obtained and then no matter how much you change arrowstyle or pointstyle, position remains unchanged... You have to test this... I'll update my attachment once again with this change...

M.R.
« Last Edit: March 27, 2014, 05:16:28 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3300
  • Marko Ribar, architect
Re: Please break my routine......
« Reply #17 on: March 27, 2014, 05:45:42 AM »
It seems that only solution is (command "_.mleader" '(0.0 0.0) '(1.0 1.0) "") that is later modified... So here is my final working version without Clipboard...

uleader-3.0g.lsp

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Please break my routine......
« Reply #18 on: March 27, 2014, 11:55:01 AM »
It seems that only solution is (command "_.mleader" '(0.0 0.0) '(1.0 1.0) "") that is later modified... So here is my final working version without Clipboard...

uleader-3.0g.lsp

M.R.
Grr....I hate when I have to use command like this, I find that it is generally slower, but I suppose one throughout the command isn't too bad. I do wonder if vl-cmdf will work, it's usually slightly faster....I'll test both and see.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Please break my routine......
« Reply #19 on: March 27, 2014, 12:57:58 PM »
Ok, I made a few changes to your code to speed this up and reduce screen flicker and updated the original post with uleader-3.0h

  • Since vla functions aren't used, removed the check for paper/model space
  • Uses the vl-cmdf function instead of the command function
  • Leader now initially draws at the correct coordinates, so there is no need to update afterwards
  • New leader is now drawn before the old one is removed to reduce screen flicker

I also had to put the end of the code back to textedit, as DDedit is no longer available in AutoCAD 2015. But I am not sure what version of Autocad this command was introduced in, so I need to do some research there.

Update: Turns out that textedit doesn't always work well in 2014 and lower, so I have updated the original code to always use DDEDIT on older versions and TEXTEDIT on newer versions. Original post has been updated with uleader-3.0i
« Last Edit: March 27, 2014, 01:16:52 PM by cmwade77 »

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: Please break my routine......
« Reply #20 on: March 28, 2014, 11:08:51 AM »
I noticed this issue on the following sequence:
1) Use "S" option to align leaders by "Y" direction.
2) Leader Flips to opposite side (shouldn't do this)
3) Grip stretch the leader to the correct side.
4) Start UL again and select "S" option to align leader segments again.
5) After selecting leader to align, I get an "Automation Error: Invalid Input", and the leader is missing its dogleg.
4) if I use "Undo" - it goes back to the point before I did the grip stretch. (If think you need to close the Undo mark in your error traping routine)

my command Line:
Code: [Select]
Command: UL

Pick starting point of leader [Select leader to change or align to]: s

Select leader that is to be aligned [Multiple/alignX/** alignY **/** alignangLe **/Note/Typ/Poc(d)/Arrowheads/Exit]:

** STRETCH **
Specify stretch point or [Base point/Copy/Undo/eXit]
Command: *Cancel*

Command: UL

Pick starting point of leader [Select leader to change or align to]: s

Select leader that is to be aligned [Multiple/** alignX **/alignY/** alignangLe **/Note/Typ/Poc(d)/Arrowheads/Exit]:
** Error: Automation Error. Invalid input **

I see three problems here:
1) On the 1st align - It should not flip the leader to the opposite side.
2) the "Automation Error" and resulting leader missing the dogleg.
3) "Undo" should only undo the last attempt at aligning, and not be altering my prior manual Grip Stretch.

Otherwise - So far your program is very nice. I like the automatic alignment feature  :-)

EDIT - NOTE: I did not see this problem when using "X" Alignment. However, the Undo still kills my previous Grip Edit. You need to look at where you undo marks are getting set and closed.

EDIT2 - Looking at your code now, I see you have not put in any Undo marks. You could solve that by putting a (vla-StartUndoMark (vla-get-activedocument (vlax-get-acad-object))) at the beginning of your "c:Uleader" routine, and (vla-EndUndoMark (vla-get-activedocument (vlax-get-acad-object))) at the end of the routine AND in your Error function.
« Last Edit: March 28, 2014, 11:35:28 AM by PKENEWELL »
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Please break my routine......
« Reply #21 on: March 28, 2014, 11:34:42 AM »
I noticed this issue on the following sequence:
1) Use "S" option to align leaders by "Y" direction.
2) Leader Flips to opposite side (shouldn't do this)
3) Grip stretch the leader to the correct side.
4) Start UL again and select "S" option to align leader segments again.
5) After selecting leader to align, I get an "Automation Error: Invalid Input", and the leader is missing its dogleg.
4) if I use "Undo" - it goes back to the point before I did the grip stretch. (If think you need to close the Undo mark in your error traping routine)

my command Line:
Code: [Select]
Command: UL

Pick starting point of leader [Select leader to change or align to]: s

Select leader that is to be aligned [Multiple/alignX/** alignY **/** alignangLe **/Note/Typ/Poc(d)/Arrowheads/Exit]:

** STRETCH **
Specify stretch point or [Base point/Copy/Undo/eXit]
Command: *Cancel*

Command: UL

Pick starting point of leader [Select leader to change or align to]: s

Select leader that is to be aligned [Multiple/** alignX **/alignY/** alignangLe **/Note/Typ/Poc(d)/Arrowheads/Exit]:
** Error: Automation Error. Invalid input **

I see three problems here:
1) On the 1st align - It should not flip the leader to the opposite side.
2) the "Automation Error" and resulting leader missing the dogleg.
3) "Undo" should only undo the last attempt at aligning, and not be altering my prior manual Grip Stretch.

Otherwise - So far your program is very nice. I like the automatic alignment feature  :-)

EDIT - NOTE: I did not see this problem when using "X" Alignment. However, the Undo still kills my previous Grip Edit. You need to look at where you undo marks are getting set and closed.
I will take a look at it, but part of the aligning process is that it is supposed to also match the dogleg length, as that is a company standard here, when I post the next version, I will try to add comments to the lines that should be commented out to remove that. But the first two errors are definitely an issue and I have also been finding some issues with the undo command, so need to setup undo marks better.

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: Please break my routine......
« Reply #22 on: March 28, 2014, 11:39:36 AM »
I will take a look at it, but part of the aligning process is that it is supposed to also match the dogleg length, as that is a company standard here, when I post the next version, I will try to add comments to the lines that should be commented out to remove that. But the first two errors are definitely an issue and I have also been finding some issues with the undo command, so need to setup undo marks better.

NOTE: When I did the Grip Stretch - I only used the leader 2nd point. I did not stretch the dogleg in any way.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Please break my routine......
« Reply #23 on: March 28, 2014, 11:41:00 AM »
I will take a look at it, but part of the aligning process is that it is supposed to also match the dogleg length, as that is a company standard here, when I post the next version, I will try to add comments to the lines that should be commented out to remove that. But the first two errors are definitely an issue and I have also been finding some issues with the undo command, so need to setup undo marks better.

NOTE: When I did the Grip Stretch - I only used the leader 2nd point. I did not stretch the dogleg in any way.
Oh, ok, then that is definitely a problem and one that I thought I resolved previously, have you downloaded the latest version (3.0i) from the first post?

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: Please break my routine......
« Reply #24 on: March 28, 2014, 11:47:38 AM »
Oh, ok, then that is definitely a problem and one that I thought I resolved previously, have you downloaded the latest version (3.0i) from the first post?

Yes - I was using version 3.0i.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: Please break my routine......
« Reply #25 on: March 28, 2014, 11:50:57 AM »
Well - I haven't had more time to diagnose all your code, but attached is a copy I made of your code with added Undo marks. just search for "Pkenewell" (my commented lines). This works for getting the undo marks correct.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Please break my routine......
« Reply #26 on: March 28, 2014, 03:59:26 PM »
Well - I haven't had more time to diagnose all your code, but attached is a copy I made of your code with added Undo marks. just search for "Pkenewell" (my commented lines). This works for getting the undo marks correct.
Thank you, that was going to be on my list for next week.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Please break my routine......
« Reply #27 on: February 11, 2015, 05:30:56 PM »
I am finally getting back to this. I believe I have all of the bugs worked out, but I would like someone to confirm this. I have also added the ability to automatically select more than one leader to align by clicking on a blank area of the drawing when trying to select a leader to align.

Please let me know if you find problems with this routine.

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: Please break my routine......
« Reply #28 on: May 23, 2016, 11:02:16 AM »
I am finally getting back to this. I believe I have all of the bugs worked out, but I would like someone to confirm this. I have also added the ability to automatically select more than one leader to align by clicking on a blank area of the drawing when trying to select a leader to align.

Please let me know if you find problems with this routine.

Hi cmwade77,

My apologies that I haven't looked at this update until now - your recent post referring to it jogged my memory. I just tried out  3.0k however and immediately noticed an issue: It is deleting any object that lies under the 1st leader point (except selecting another mleader of course).

It has to do with the following lines in your code within the grread loop for re-writing the MLEADER object:
Code: [Select]
(if (and (/= mlobj nil) (not (vlax-erased-p mlobj)))
(vla-delete mlobj)
)

I think you are reusing the variable "mlobj" for the new MLEADER object without clearing it first from its usage at the first point selection, so it deletes the object under the selection before deleting the new MLEADER within the grread loop.

I solved the issue by adding a setq to clear the variable "mlobj" if the selected object is not a multileader:

Code: [Select]
(if (wcmatch (cdr (assoc 0 (entget (car ent)))) "*MULTILEADER*")
   (progn
      ;;; Your Modify mleader code ...
   )
   (setq mlobj nil) ;; Added this to clear the variable before it is used again.
)

Since it has been while you might have already solved this issue. If that is the case however, you should post your latest code in the first post of this thread if you are offering it as a solution for others.

This is an excellent program otherwise - very good work. It has helped me out with some of my own code structures for sure!  :-D
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Please break my routine......
« Reply #29 on: May 23, 2016, 11:35:43 AM »
I am finally getting back to this. I believe I have all of the bugs worked out, but I would like someone to confirm this. I have also added the ability to automatically select more than one leader to align by clicking on a blank area of the drawing when trying to select a leader to align.

Please let me know if you find problems with this routine.

Hi cmwade77,

My apologies that I haven't looked at this update until now - your recent post referring to it jogged my memory. I just tried out  3.0k however and immediately noticed an issue: It is deleting any object that lies under the 1st leader point (except selecting another mleader of course).

It has to do with the following lines in your code within the grread loop for re-writing the MLEADER object:
Code: [Select]
(if (and (/= mlobj nil) (not (vlax-erased-p mlobj)))
(vla-delete mlobj)
)

I think you are reusing the variable "mlobj" for the new MLEADER object without clearing it first from its usage at the first point selection, so it deletes the object under the selection before deleting the new MLEADER within the grread loop.

I solved the issue by adding a setq to clear the variable "mlobj" if the selected object is not a multileader:

Code: [Select]
(if (wcmatch (cdr (assoc 0 (entget (car ent)))) "*MULTILEADER*")
   (progn
      ;;; Your Modify mleader code ...
   )
   (setq mlobj nil) ;; Added this to clear the variable before it is used again.
)

Since it has been while you might have already solved this issue. If that is the case however, you should post your latest code in the first post of this thread if you are offering it as a solution for others.

This is an excellent program otherwise - very good work. It has helped me out with some of my own code structures for sure!  :-D
My apologies, I thought the current version posted had worked, I will look at this change in a little bit and make sure that it is in my latest version just in case it is wrong there too and update it.