Page 1 of 1

help with my piping endcap code please.

Posted: Wed Feb 01, 2023 9:54 am
by sln8458
in version 10.1 I was able to create a 3d solid of an endcap:
Image
.

However when version 11.0 was released, my lisp stoped working :( This was apparently due to a bug in the code for version 10.1 which was fixed in 11.0.
Since then I have been trying to find a way around the problem. Now on version 11.1

The problem was, I was creating a 2D closed polyline which I was trying to REVOLVE around its centreline. Icad didn't like this. Finally came up with an idea where I create an open polyline, trim back to the ceNtre line and then revolve this. This works, but only some of the time. (see zip file attched below for current code)

Here is a snipet of the code to trim the open polyline

Code: Select all

;--------------------------------------------------------------------
;	-	trim shell to line
	(progn
		(command "_ucs" "w" "")
		(command "_trim" ENTLN1 ENTDH3 "" TP04 "")
		(setq ENTDH3A (entlast))
		(command "_trim" ENTLN1 ENTDH3A "" TP02z1 "")
	)	;end progn		
;-----------end trim shell
This works sometimes and not others, both TP04 & TP02z1 are away from the line to TRIM to.
When this does not work, there appears to be 2 polylines at the same point. But I'm only creating 1.

SteveN

The full code is available in the FREE DWG SECTION.

Re: help with my piping endcap code please.

Posted: Wed Feb 01, 2023 11:55 pm
by QuanNguyen
Hi Steven,
I am afraid people don't have time to download and try to run your code.
It would be best if you post the code that can run, I mean that it has all values for the variables.
Regards,

Re: help with my piping endcap code please.

Posted: Thu Feb 02, 2023 1:37 am
by sln8458
Hi Quan,

I understand what you are saying. Trouble is the randomness of the problem.

Here are a couple of videos of the shape being created & failing.

2D polyline (note: the small line is me proving that the trim selection points are away from the line to trim to):
https://www.dropbox.com/s/omf0zqns964um ... 4.avi?dl=0

And here is the 3D shape being created, including a failure:
https://www.dropbox.com/s/69r94wp4y7evd ... 1.avi?dl=0

The command line lists:
The object should be on one side of the axis.
Unable to revolve 1 selected curve(s)
Why fail? when it's using the same code as previous??

SteveN

Re: help with my piping endcap code please.

Posted: Thu Feb 02, 2023 3:11 am
by sln8458
Just in case, attached is the lsp/dcl & dimension files only for the End Caps.

Re: help with my piping endcap code please.

Posted: Thu Feb 02, 2023 9:34 pm
by QuanNguyen
Hi Steven,

Try to zoom into the entity and turn off the snap before calling the command TRIM.

Code: Select all

		(command "_ucs" "w" "")
		(command "-zoom" "ENtity" ENTDH3 "")
		(command "_trim" ENTLN1 ENTDH3 "" TP04 "")
		(setq ENTDH3A (entlast))
		(command "_trim" ENTLN1 ENTDH3A "" TP02z1 "")
		(command "-zoom" "Previous")

Re: help with my piping endcap code please.

Posted: Fri Feb 03, 2023 1:25 am
by sln8458
Thankyou Quan,

Code: Select all

	(progn
		(command "_ucs" "w" "")
		(command "-zoom" "ENtity" ENTDH3 "") ; from Quan
		(command "_trim" ENTLN1 "" TP04 "")
;		(setq ENTDH3A (entlast))
		(command "_trim" ENTLN1 "" TP02z1 "")
		(command "-zoom" "P" "") ; from Quan
;		(setq ENTDH3A (entlast))
	)	;end progn	
That works :)

But why the zoom?

Re: help with my piping endcap code please.

Posted: Sat Feb 04, 2023 2:51 am
by sln8458
Having used the new code for a short while I feel that the 'zoom' in the middle of the component generation will not be suitable on a daily use basis.

So I have decided to try an alternative approach.
In the image below at the bottom is my template for the endcap. with all of the points used to create the shape in white.
I hope to add the 2 new points in red. and use those as the start/finish of the revised shape (top of the image belwo) prior to the 3D revolve. This way I can ommit the need for the TRIM, and also the zoom'.
.
Image
Fortunately I already have the location of ET01, relative to the origin of the shape creation, in the data imported from the dimension file(s)
Sorry for the poor image, but it's the top dim 'E' in the piping dialog on the right.
I also have the location of ET02 as that is ET01 - the wall thickness of the end cap (dim Wall T, 3rd down in the dialog).

Sounds good when I write it down, now to remember how I did it and repeat :)

SteveN

Re: help with my piping endcap code please.

Posted: Sun Feb 05, 2023 3:29 am
by sln8458
I've run into a problem I don't understand! (code attached.

I've added a few 'princ' comments into the code so I can see how things are progressing

Code: Select all

    (princ (strcat "\nCurrent status for DH:HOD$ is : = " DH:HOD$ " "))

this is before I actually modify anything and is what I expect drwing the profile:
Command:
Goto DH_SSP Set Size Parameters Function
Current status for DH:HOD$ is : = 610
Current status for DH:HTHK$ is: = 46.05
Current status for DH:SFLG$ is: = 129.48
Current status for DH:HDHT$ is: = 305
Current status for HOD$ is : = 610
Current status for HTHK$ T is : = 46.05
Current status for SFLG$ is: = 129.48
Current status for HDHT$ E is : = 305
Goto DH_CDH calculate dished head function
Goto DH_OLL outside arc Point/Bulge list
Goto DH_T_LN DRAW A STRAIGHT PLINE
Goto DH_DDH Draw Dished Head Profile
Command:

However as soon as I remove the ';' from this line

Code: Select all

 ;    (princ (strcat "\nCurrent status for HOD# is : = " HOD# " "))

The code effectively stops??
Goto DH_SSP Set Size Parameters Function
Current status for DH:HOD$ is : = 610
Current status for DH:HTHK$ is: = 46.05
Current status for DH:SFLG$ is: = 129.48
Current status for DH:HDHT$ is: = 305
Current status for HOD$ is : = 610
Current status for HTHK$ T is : = 46.05
Current status for SFLG$ is: = 129.48
Current status for HDHT$ E is : = 305
error: bad argument type

This is where HOD# is defined, note: all 4 '#' have the same result!

Code: Select all

  (setq HOD$  DH:HOD$					;HOD$ is the main OD.
        HTHK$ DH:HTHK$					;HTHK# is the wall thickness.
        SFLG$ DH:SFLG$					;SFLG$ is the flange straight length.
	HDHT$ DH:HDHT$					;HDHT$ is the Cap length 'E'
        HOD#  (distof HOD$  2)				;distof converts string to real value, 2 = decimal
        HTHK# (distof HTHK$ 2)
        HTHT# (distof HTHT$ 2)		
        SFLG# (distof SFLG$ 2)
        HID#  (- HOD# (* HTHK# 2))
        THKL$ DH:THKL$
	);end setq
What am I missing/forgotten?
As later on in the code I want to use this:

Code: Select all

    (setq   ET02A (- HDHT# HTHK#))	;distance from origin to inside End Cap	
But I get the same error: bad argument type
Steve

Re: help with my piping endcap code please.

Posted: Mon Feb 06, 2023 1:49 am
by QuanNguyen
Hi Steven,

Because the type of "HOD#" variable is real

Code: Select all

        HOD#  (distof HOD$  2)		;distof converts string to real value, 2 = decimal
so we need to convert to string when using the function strcat:
(strcat "\nCurrent status for HOD# is : = " (rtos HOD# ) " ")

Re: help with my piping endcap code please.

Posted: Mon Feb 06, 2023 2:30 am
by sln8458
Thanks Quan,

I was just comming on to post I had finally remembered

Code: Select all

    (princ (strcat "\nCurrent status for HOD# is : = " (rtos HOD#) " "))
	(princ "\n HOD# =")
	(PRINC HOD#)
I used the other method below it until the penny dropped !
SteveN

Re: help with my piping endcap code please.

Posted: Tue Feb 07, 2023 2:04 am
by sln8458
All sorted now, and a new version added to the FREE DRAWINGS page.

SteveN