Author Topic: Block replacement lisp  (Read 30558 times)

0 Members and 1 Guest are viewing this topic.

M-dub

  • Guest
Re: Block replacement lisp
« Reply #15 on: February 26, 2006, 04:37:04 PM »
Some good points, there MP.
Points I hadn't really thought of until I read your post.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Block replacement lisp
« Reply #16 on: February 26, 2006, 08:48:54 PM »
Yes, quite an eye opener.  :oops:
Especially when my code looked like that no too long ago.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Chuck Gabriel

  • Guest
Re: Block replacement lisp
« Reply #17 on: February 27, 2006, 08:28:15 AM »
Yes, quite an eye opener.  :oops:
Especially when my code looked like that no too long ago.

I know I've done worse.

Joe Burke

  • Guest
Re: Block replacement lisp
« Reply #18 on: February 28, 2006, 09:34:44 AM »
What the ... I thought this was the swamp ... this kind of attitude belongs back at the Autodesk new server.

Fact is, the last version of the code in question here was written 6 years ago according to its header (I would safely guess it predates Autodesk Express Tool) -- we don't know if there is a more up to version, or if he only spent 5 minutes on it.

Michael,

The code does not predate Express Tools which were free with AutoCAD 2000. Here's a link to a Cadalyst article by Lynn Allen: http://tinyurl.com/p2zgj  The code is dated a year after that article.

Regarding "this kind of attitude...", what are you saying? That I should only post comments which are polite and politically correct? Otherwise expect to be admonished?

Regards

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Block replacement lisp
« Reply #19 on: February 28, 2006, 10:09:44 AM »
On a tangent...kinda:

Why does this code not match the rotation of the block being replaced? For example...a block that has a rotation of 45 is replaced with a block that has a rotation of 58?

;;  Function to copy blocks from one point to another

Code: [Select]
(defun c:Replaceblocks
       (/ ent1 ent2 obj1 obj2 pt1 pt2 x ss index keyw rot r2d)
  (command ".undo" "begin")
  (while
    (= ent1 nil)
     (setq ent1 (car (entsel "\n Select block to copy: ")))
     (if (= ent1 nil)
       (alert "\n You missed, try again...")
     )
  )
  (while
    (= ent2 nil)
     (setq ent2 (car (entsel "\n Select block you want to swap: ")))
     (if (= ent2 nil)
       (alert "\n You missed, try again...")
     )
  )
  (setq obj1 (vlax-ename->vla-object ent1)
pt1  (trans (vlax-get obj1 'insertionpoint)0 1)
  )
  (setq obj2 (vlax-ename->vla-object ent2)
   x (vlax-get-property obj2 'Name)
  )
  (start-timer)
  (if
    (and
      (= (vla-get-ObjectName Obj1) "AcDbBlockReference")
      (not (vlax-property-available-p Obj1 'Path))
    )
     (progn
       (if (not *default*)
(setq *default* "Select")
       )
       (initget 0 "Select All")
       (setq keyw
      (cond
((getkword
   (strcat "\nEnter selection option (Select / All): <<"
   *default*
   ">>: "
   )
)
)
(*default*)
      )
       )
       (setq *default* keyw)
       (cond
((= Keyw "Select") (setq SS (ssget (list (cons '2 x)))))
((= Keyw "All") (setq SS (ssget "X" (list (cons '2 x)))))
       )
       (setq
index -1
       )
       (while (< (setq index (1+ index)) (sslength ss))
(setq obj  (ssname ss index)
       obj2 (vlax-ename->vla-object obj)
       pt2  (trans (vlax-get obj2 'insertionpoint)0 1)
       rot  (vlax-get obj2 'Rotation)
)
         (vla-put-rotation obj1 rot)
(vl-cmdf "_copy" ent1 "" pt1 pt2 "")
       )
     )
  )
  (princ)
  (command "_erase" ss "")
  (command ".undo" "end")
  (princ)
  (princ (strcat (itoa index) " blocks swapped."))
)

Thanks,

Ron
« Last Edit: February 28, 2006, 02:39:35 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Serge J. Gianolla

  • Guest
Re: Block replacement lisp
« Reply #20 on: February 28, 2006, 02:32:29 PM »
Quote
a block that has a rotation of 45 is replaced with a block that has a rotation of 58?

Have not tested your code, but still taking a punt.
Angles given in deg. instead of radians or vice versa are often the culprits.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Block replacement lisp
« Reply #21 on: February 28, 2006, 02:40:41 PM »
I was making it harder than it needed to be. There was no need to try and convert the rotation.  :ugly:

I updated the code above.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Block replacement lisp
« Reply #22 on: March 01, 2006, 09:43:25 AM »
The code does not predate Express Tools which were free with AutoCAD 2000. Here's a link to a Cadalyst article by Lynn Allen: http://tinyurl.com/p2zgj The code is dated a year after that article.

You could very well be correct (I can't view tiny urls from here -- the IT dep't thinks unspeakable evil will occur apparently). Fact is I historically don't use or recommend Bonus / Express tools to other programmers so admit I'm not up to speed on what they contain. Nonetheless, like the other author, I would tend to write my own version and yes, because I'm protecting my job. Not in the way that you suggest, but from a reliability perspective. I need to be able to ensure a solution is available to any CADD station. Fact is over the last decade Autodesk has been completely inconsistant with the Bonus / Express tools grab bag to the point you can not (legally) count on it being on a candidate CADD station.

Regarding "this kind of attitude...", what are you saying? That I should only post comments which are polite and politically correct? Otherwise expect to be admonished?

Regards

In short yes, err on the side of kindness. If you want to minimize or belittle the efforts of others ala Godzillo please post to that other news server, otherwise post here as if you are speaking to friends face to face -- even if they are not here. While it is a high bar, one that I have publically struggled with myself, it is a goal worth aspiring to lest this great place degrade to the kind of chilly rooms found elsewhere.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Block replacement lisp
« Reply #23 on: March 01, 2006, 11:16:09 AM »
I am reading and reading and reading again... what Joe posted... and I do not see any problem with his comment... I simple do not get it or do not understand...

I see he is just making a point as a professional... nothing else...

Or what is happening then?

Thanks;
Luis Esquivel

You think this is acceptable?

Maybe I don't get it, but I fail to see what's interesting about Luis' bloated code.

<snip>

Luis' Magic ... ? That should tell you that Luis is probably a CAD manager more interested in protecting his job than writing good code. If Luis is around, I won't retract that statement.

A courteous "professional" would say something like --

Doesn't the express tools do the same thing?

Or ...

Here's an alternative way to achieve same that is a little more elegant / efficient.

Forgo the attitude, making assumptions / accusations / character assassinations that do nothing but incite arguments and / or animosity.

In short, I didn't find the dialogue in keeping with the "share ideas, resources and information in a friendly, helpful context" swamp mantra, the one thing that has made this place different than other forums.

In my opinion of course.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Block replacement lisp
« Reply #24 on: March 01, 2006, 11:41:31 AM »
I am not the original author of that code... btw, I helped back then on 2001 [I think] to the author and told him, about why a code that was part of a contest, was really bad structured... If I recall correctly.

 :-)

That wasn't my point. My point was how would you feel if that language was directed at you?

I do however, have no doubt that you probably helped out the original author in a friendly, disarming manner.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Block replacement lisp
« Reply #25 on: March 01, 2006, 12:59:42 PM »
I am reading and reading and reading again... what Joe posted... and I do not see any problem with his comment... I simple do not get it or do not understand...

I see he is just making a point as a professional... nothing else...

Or what is happening then?

Thanks;
Luis Esquivel

You think this is acceptable?

Maybe I don't get it, but I fail to see what's interesting about Luis' bloated code.

<snip>

Luis' Magic ... ? That should tell you that Luis is probably a CAD manager more interested in protecting his job than writing good code. If Luis is around, I won't retract that statement.

A courteous "professional" would say something like --

Doesn't the express tools do the same thing?

Or ...

Here's an alternative way to achieve same that is a little more elegant / efficient.

Forgo the attitude, making assumptions / accusations / character assassinations that do nothing but incite arguments and / or animosity.

In short, I didn't find the dialogue in keeping with the "share ideas, resources and information in a friendly, helpful context" swamp mantra, the one thing that has made this place different than other forums.

In my opinion of course.

I totally agree MP. I found the comments to be rude. I am definitely not the best lisp writer. I never hesitate to post anything I've done here on the Swamp because I know that the swamp is a place to contribute help in a tactful manner.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Block replacement lisp
« Reply #26 on: March 01, 2006, 03:01:30 PM »
I totally agree MP. I found the comments to be rude. I am definitely not the best lisp writer. I never hesitate to post anything I've done here on the Swamp because I know that the swamp is a place to contribute help in a tactful manner.

Ron

Thank you Ron. I was feeling I was on my own on this (but not about to back down either). I really appreciate you stepping up to voice your opinion and acknowledge mine. A lot.

<thumbs up icon goes here>
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Block replacement lisp
« Reply #27 on: March 01, 2006, 03:13:33 PM »
MP
I totally agree with your position.
Silence due to embarrassment over my unthinking first response.

The swamp is a great place for all CAD people of any level or interest.
Let's keep it that way.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Block replacement lisp
« Reply #28 on: March 01, 2006, 03:48:38 PM »
I know Joe and I know he is a professional... and cannot see any bad part on his comment... maybe is my English translation level... but I don't think so.

I have seen worst comments coming from someone that all here know very well....

Sorry Luis but it's not about whether you know someone as a pro or not but whether the dialog was rude. As for comparisons, of what value is that? So and so is not as bad as so and so -- so it's ok? Horse pucky. As the target of much undeserved rudeness yourself I find your take quite baffling, though I respect you for defending Joe.

I'm done.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Chuck Gabriel

  • Guest
Re: Block replacement lisp
« Reply #29 on: March 01, 2006, 03:55:07 PM »
I really hate to get entangled in things like this, especially when there are people I like and respect on both sides of the argument, but I have to say I agree with MP.  I prefer to be treated with respect, and so I try to treat others with respect.