Author Topic: Code works, but then it does't ??  (Read 2269 times)

0 Members and 1 Guest are viewing this topic.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Code works, but then it does't ??
« on: March 06, 2021, 05:19:20 AM »
Hi Guys, I need your help again pls.

I have attached 2 lsp files, BLD & Piping.

I have been working on the creation of Blind Flange blocks created on the fly rather than inserting them from a folder. I have completed the simple Flat Face & the Raised Face Blinds. The BLD code is for the Ring Type Joint faced Blind Flanges, which works as a stand alone routine. However when merged into the main Piping file the code fails during the 'insert' command??

Command window info
Quote
Command: _.-insert
[? to list blocks in drawing/BROWSE/EXPLORE]/<Block to insert> <BLRTJ_#150_18-3D>: BLRTJ_#150_18-3D
[Scale/X/Y/Z/Rotation/Multiple]/<Insertion point for block>: 0,0,0
[Corner/XYZ]/X scale factor <1.000000>:
Error: Function cancelled

So the strange thing is that I use the same code for inserting the created blocks??
If works for the Flat Face Flanges and works for the Raised Face Flanges but NOT the RTJ Flanges
Code: [Select]
(defun INS_BLD ()
(command "ucs" "ZA" INPT IANG)
        (if (tblsearch "block" BLD1)
        (progn
        (command "_.-insert" BLD1 "0,0,0" insertscal "" "0"))
); end IF
(command "_ROTATE3D" "L" "" "X" "0,0,0" "270")
(command "ucs" "w" "")
(princ)
  )

Can anyone offer and suggestions pls
S.
Just added a couple of 'dim' files, txt files required containing details for the flanges
« Last Edit: March 08, 2021, 06:05:02 AM by sln8458 »
There is no such  thing as a 'silly question' to those who do not know!

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Code works, but then it does't ??
« Reply #1 on: March 08, 2021, 12:32:07 PM »
Not a direct answer to you question, but I used this software in the past and it has quite the library of fittings and pipe.
https://www.asvic.com.au/index.php?com=com_content&itemid=35

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: Code works, but then it does't ??
« Reply #2 on: March 08, 2021, 02:55:01 PM »
Not a direct answer to you question,  but I used this software in the past and it has quite the library of fittings and pipe.
https://www.asvic.com.au/index.php?com=com_content&itemid=35

Cheers for the link Ron.
I have seen that in the past,but at that time I felt it was too expensive, so a created my own library. Over time this grew to the point I felt I needed to 'organise' it a bit more, so generated pull-down menus. Then added more bits and decided that I should have a go at my own LISP/DCL dialogue, however I was too busy with work. Since Covid work fell off a cliff, so I have the time and my first attempt was purely a 'block insertion' tool/library. Now I've had a 'play' with entmake I'm trying to create the blocks 'on the fly'. It helps fill the time I have to spare, and, if when I'm done anyone wants a copy they can.

S
There is no such  thing as a 'silly question' to those who do not know!

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Code works, but then it does't ??
« Reply #3 on: March 08, 2021, 03:03:12 PM »
Not a direct answer to you question,  but I used this software in the past and it has quite the library of fittings and pipe.
https://www.asvic.com.au/index.php?com=com_content&itemid=35

Cheers for the link Ron.
I have seen that in the past,but at that time I felt it was too expensive, so a created my own library. Over time this grew to the point I felt I needed to 'organise' it a bit more, so generated pull-down menus. Then added more bits and decided that I should have a go at my own LISP/DCL dialogue, however I was too busy with work. Since Covid work fell off a cliff, so I have the time and my first attempt was purely a 'block insertion' tool/library. Now I've had a 'play' with entmake I'm trying to create the blocks 'on the fly'. It helps fill the time I have to spare, and, if when I'm done anyone wants a copy they can.

S
Good for you ... fill that down time with code :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Code works, but then it does't ??
« Reply #4 on: March 08, 2021, 11:21:41 PM »
Flanges can be done by using a pre-made block library and programming.

Here is a nice LSP that I have used for ages. It draws 2d and 3d steel sections. You can have a look although it may not be the way you are working with.

BTW I've learned and customsied it for my needs.

Download it if you like and learn from there. Then you probably can make some changes for flange (2d/3d), if you have time.  :-D
http://www.cadutils.com/item/27-stl-steel-shapes

Plus this for drawing 2d flange.
https://cadtips.cadalyst.com/standard-blocks/draw-pipe-flanges

HTAH (Hope This Also Helps)  :-)

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: Code works, but then it does't ??
« Reply #5 on: March 09, 2021, 03:22:55 AM »
Flanges can be done by using a pre-made block library and programming.

Here is a nice LSP that I have used for ages. It draws 2d and 3d steel sections. You can have a look although it may not be the way you are working with.

BTW I've learned and customsied it for my needs.

Download it if you like and learn from there. Then you probably can make some changes for flange (2d/3d), if you have time.  :-D
http://www.cadutils.com/item/27-stl-steel-shapes

Plus this for drawing 2d flange.
https://cadtips.cadalyst.com/standard-blocks/draw-pipe-flanges

HTAH (Hope This Also Helps)  :-)

Thanks MeasureUp.

I already have ALL of the 3D blocks.
I have a copy of a similar utility which I modified to include the UK steel sections,

 sent it back to the author for inclusion on his web blog here
https://blog.draftsperson.net/wiseys-steel-shapes-lisp-program/

S.
There is no such  thing as a 'silly question' to those who do not know!

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Code works, but then it does't ??
« Reply #6 on: March 09, 2021, 03:24:17 AM »
Returning to the original problem:
Try checking insertscal before the insert command. It may hold an unexpected value.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: Code works, but then it does't ??
« Reply #7 on: March 09, 2021, 06:39:42 AM »
Returning to the original problem:
Try checking insertscal before the insert command. It may hold an unexpected value.

insertscal from command line (princ)
Quote
Command: sln_piping
Current status for insertscal is: = 1.000
Current VERSION for the lisp file is: = 2.0.8H-ICAD10

Changing the code to replace insertscal with 1
Code: [Select]
(command "_.-insert" BLD1 "0,0,0" "1" "" "0"));insertscal
Appears to solve the initial problem, but leave me with the problem of imperial scaling to overcome.

Also, more importantly is why the issue in the first place?? as the code works fine for the other 2 types of flanges??

S.

There is no such  thing as a 'silly question' to those who do not know!

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Code works, but then it does't ??
« Reply #8 on: March 09, 2021, 08:03:41 AM »
Try checking the value of insertscal immediately before calling the  insert command. I do not think you are doing that right now.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: Code works, but then it does't ??
« Reply #9 on: March 09, 2021, 11:04:54 AM »
Thanks Roy,

Your pointer helped, though it wasn't 'insertscal' that was the issue, but these three
ENT1, ENT2, ENT3.

I had used the same variable name in the 3 functions (declared as local), however the value for 'insertscal' popped up where ENT3 was expected??
Anyway re-named the variables as ENTFF1/2/3, ENTRF1/2/3 & ENTRTJ1/2/3 and it is all working as expected.

I don't understand why the cross pollination of variable values.
I thought that if they were declared local (/ var1 var2....) then they would be cleared when the function ends.
Still, lesson learnt, keep to unique variable names!!!!

S.
There is no such  thing as a 'silly question' to those who do not know!